jest
을 사용하여 다음 단위 테스트를 만들려고합니다.`TypeError : jest.fn이 함수가 아닙니다. '
jest.dontMock("pointsAwardingActions.js");
describe("points awarding actions",() => {
describe("award points",() => {
it("should dispatch begin ajax action",() => {
var pointsAwardingActions = require("pointsAwardingActions.js");
const mockedDispatch = jest.fn();
});
});
});
그러나 npm test
을 실행 한 후에 다음 오류가 발생합니다.
TypeError: jest.fn is not a function
이
내package.json
의 일부 섹션입니다.
{
"scripts": {
"test": "jest"
},
"author": "alayor",
"license": "ISC",
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
"testFileExtensions": ["spec.js"],
"moduleFileExtensions": ["js"],
"collectCoverage": "true"
},
"dependencies": {
"babel-cli": "6.8.0",
"babel-core": "6.8.0",
"babel-jest": "^6.0.1",
"babel-loader": "6.2.4",
"babel-plugin-react-display-name": "2.0.0",
"babel-polyfill": "6.8.0",
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-react-hmre": "1.1.1",
"expect": "1.19.0",
"express": "4.13.4",
"jest": "^0.1.40",
"jest-cli": "^0.8.1",
...
}
}
내가 그 오류를 표시하는 이유가 무엇일 수 있습니다.
이 같은 오류가 표시 : 직접 농담 개체를 가져올 경우, 당신은 경유하여 농담-모의 모듈이 아닌 농담-CLI 모듈을 가져올. – Swordfish0321
나는 21.2.1에 있는데이 같은 오류를 보았습니다 – TFischer