我正在使用Jest来测试我的Node.JS应用程序,当我运行我的测试时,一些内置函数不起作用,似乎它们没有被定义.例如,toContainEqual和toBeInstanceOf.
这是我的代码示例:
it('should delete DB entry', () => query(url, queryString)
.then(res => res.json()
.then(() => db.collection('exercises').find({}).toArray()))
.then(res => expect(res).toContainEqual(originalExercise)))
Run Code Online (Sandbox Code Playgroud)
而我得到的错误:
TypeError: expect(...).toContainEqual is not a function
Run Code Online (Sandbox Code Playgroud)
但其他功能(如toEqual,toBeTruthy)工作正常.
我正在使用Jest v15.1.1(根据jest -v).
我怎么处理它?
toContainEqual并且toBeInstanceOf尚未包含在v15.1.1中.要使用这两个匹配器,您需要安装jest@15.2.0-alpha.c681f819,或者只是等待下一个版本.
根据Jest代码历史,toContainEqual于9月20日合并(https://github.com/facebook/jest/pull/1706)并toBeInstanceOf于9月7日合并(https://github.com/facebook/jest/拉/ 1625).但是,v15.1.1于9月2日发布.
似乎应该更改Jest的API页面,以便不包含未发布的API.
| 归档时间: |
|
| 查看次数: |
2879 次 |
| 最近记录: |