我在Redux上關注Dan Abramov的教程。 (https://egghead.io/lessons/javascript-redux-avoiding-object-mutations-with-object-assign-and-spread)TypeError:expect(...)。toEqual不是函數
在本課的9,他介紹了測試和使用expect
和.toEqual()
這是我的代碼:
var expect = require('chai').expect;
var freeze = require('deep-freeze-node');
const testToggleTodo =() => {
const todoBefore = {
id: 0,
text: 'Learn Redux',
completed: false
};
const todoAfter = {
id: 0,
text: 'Learn Redux',
completed: true
};
expect(
toggleTodo(todoBefore)
).toEqual(todoAfter)
}
testToggleTodo();
console.log('All tests passed.')
,我不斷收到錯誤:
.../react_redux/src/a.js:24
).toEqual(todoAfter)
^
TypeError: expect(...).toEqual is not a function
什麼時我做錯了?我逐字複製他的代碼,但它會導致錯誤。
真理的來源始終是官方文檔中未在別人的博客:http://chaijs.com/guide/styles/#expect – zerkms