1
我是新來的笑話。我遇到了圓形CI上的錯誤。我的setup.js
文件具有ES6語法。由於每次運行測試時都會執行setupTestFrameworkScriptFile
上的文件,因此我認爲我可以使用ES6語法,但babel-jest不會將其傳輸。定期測試,例如反應組分的單元測試被傳輸。在本地環境中,安裝文件會被轉儲。Jest setupTestFrameworkScriptFile或setupFiles ES6語法
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest/node_modules/jest-cli/node_modules/jest-runtime/build/script_transformer.js:305:17)
at Object.<anonymous> (test/setup.js:1:869)
at next (native)
我的笑話配置文件看起來像這樣。
{
"verbose": true,
"transform": {
"^.+\\.(js|jsx)$": "babel-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!my-module)"
],
"snapshotSerializers": [
"jest-serializer-enzyme"
],
"setupTestFrameworkScriptFile": "<rootDir>/test/setup.js",
"globals": {
"__PROD__": false,
"__STG__": false
},
"moduleDirectories": [
"node_modules"
],
"testRegex": "(/__tests__/.*|__test__.js)$",
"moduleFileExtensions": [
"css",
"jsx",
"js",
"scss",
"svg"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/fileMock.js",
"^.+\\.(css|less|scss)$": "<rootDir>/test/styleMock.js"
}
}
我是否錯過任何設置?
你如何運行你的測試?最新的Node版本本身支持ES6(當然除了模塊語法)。 –