[英]JEST testing, getting error on import of configure from enzyme
I'm trying to run my tests in repo here: https://github.com/Futuratum/moon.holdings我正在尝试在此处的 repo 中运行我的测试: https : //github.com/Futuratum/moon.holdings
But I'm getting the following error但我收到以下错误
/Users/leongaban/projects/Futuratum/moon.holdings/jest.config.js:1 (function (exports, require, module, __filename, __dirname) { import { configure } from 'enzyme'
/Users/leongaban/projects/Futuratum/moon.holdings/jest.config.js:1 (function (exports, require, module, __filename, __dirname) { import { configure } from 'enzyme'
My tests use to work and I haven't changed anything, so curious as to what could be causing this problem?我的测试过去一直有效,但我没有改变任何东西,所以很好奇可能导致这个问题的原因是什么?
My jest.config.js file looks correct:我的jest.config.js文件看起来正确:
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
configure({ adapter: new Adapter() })
package.json包.json
{
"name": "moon.holdings",
"version": "2.0.0",
"description": "Moon Holdings: track your cryptocurrency portfolio.",
"main": "index.js",
"scripts": {
"dev": "next -p 7777",
"build": "next build",
"start": "next -p 7777",
"test": "NODE_ENV=test jest --watch --no-cache",
"test-win": "SET NODE_ENV=test&& jest --watch"
},
"author": "Futuratum",
"license": "UNLICENSED",
"dependencies": {
"@zeit/next-sass": "^1.0.1",
"@zeit/next-typescript": "^1.1.1",
"axios": "^0.18.0",
"decko": "^1.2.0",
"next": "^8.0.4-canary.10",
"next-routes": "^1.4.2",
"node-sass": "^4.11.0",
"ramda": "^0.26.1",
"ramda-adjunct": "^2.17.0",
"react": "^16.7.0",
"react-adopt": "^0.6.0",
"react-dom": "^16.7.0",
"react-ga": "^2.5.7",
"react-redux": "^6.0.0",
"react-transition-group": "^2.5.0",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"styled-components": "4.0.3",
"tslint": "^5.12.1",
"tslint-react": "^3.6.0",
"typescript": "^3.2.4",
"waait": "^1.0.2"
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.3.0",
"@babel/preset-typescript": "^7.1.0",
"@types/enzyme": "^3.1.15",
"@types/jest": "^23.3.13",
"@types/next": "^7.0.6",
"@types/ramda": "^0.25.49",
"@types/react": "^16.7.20",
"@types/react-dom": "^16.0.11",
"@types/react-redux": "^7.0.1",
"@types/styled-components": "4.0.3",
"@types/zeit__next-typescript": "^0.1.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.1.0",
"babel-plugin-sass-vars": "^0.2.1",
"babel-plugin-styled-components": "^1.10.0",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"enzyme-to-json": "^3.3.4",
"jest": "^24.1.0"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
"testPathIgnorePatterns": [
"<rootDir>/.next/",
"<rootDir>/node_modules/"
],
"transform": {
".*": "babel-jest",
"^.+\\.js?$": "babel-jest",
"^.+\\.ts?$": "babel-jest",
"^.+\\.tsx?$": "babel-jest"
},
"moduleFileExtensions": [
"js",
"json",
"ts",
"tsx"
],
"modulePaths": [
"<rootDir>/components/",
"<rootDir>/pages/",
"<rootDir>/shared/"
]
}
}
Looks like you accidentally renamed jest.setup.js
to jest.config.js
in this commit .像你看起来偶然重命名
jest.setup.js
到jest.config.js
在这次提交。
Change it back to jest.setup.js
and it should work.将其改回
jest.setup.js
,它应该可以工作。
Details细节
jest.config.js
is a special file that is used to set Jest
configuration options . jest.config.js
是一个特殊的文件,用于设置Jest
配置选项。
enzyme
configuration is typically done in a setupTestFrameworkScriptFile
file for older versions of Jest
or setupFilesAfterEnv
for newer versions of Jest
. enzyme
配置通常在setupTestFrameworkScriptFile
文件中完成,用于旧版本的Jest
或setupFilesAfterEnv
用于新版本的Jest
。
Your package.json
has setupTestFrameworkScriptFile
set to jest.setup.js
.您的
package.json
已将setupTestFrameworkScriptFile
设置为jest.setup.js
。
Based on that info I suspected that maybe jest.setup.js
got accidentally renamed, and was able to find the commit where it happened in the repo history.基于这些信息,我怀疑
jest.setup.js
可能被意外重命名,并且能够在 repo 历史记录中找到它发生的提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.