运行笑话会出现以下错误 正在运行未经测试的文件的覆盖范围...无法从/Users/****/****/somefile.js收集覆盖范围 错误:“导入”和“导出”可能仅与“ sourceType:“模块””一起出现(3:0) 堆栈:SyntaxError:“导入”和“导出”可能仅与“ sourceType:“模块””(3:0)一起出现
我尝试了babel-jest,但也没有用。这里可能是什么问题,为什么在这里未标识导入和导出??
/ * somefile.js的内容* / somefile.js
export * from './file-1';
export * from './file-2';
/ * babelrc conf * /
"test": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"edge >= 12",
"explorer >= 10"
]
}
}
],
"react",
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": true
}
],
"lodash",
"react-hot-loader/babel",
"recharts",
"transform-class-properties",
"transform-decorators-legacy",
"transform-object-rest-spread",
"transform-runtime"
]
}
/ *笑话配置* /
module.exports = {
testEnvironment: 'node',
testRegex: '.*_spec\\.(js|jsx)$',
collectCoverageFrom: [
'src/**/*.{js,jsx}',
"!<rootDir>/node_modules/**"
],
testURL: 'http://localhost/',
setupFiles: [
'<rootDir>/config/jest/SetupStorageMock.js'
],
setupTestFrameworkScriptFile: '<rootDir>/node_modules/some-jest/src/SetupReactEnzyme.js',
moduleFileExtensions: ['js', 'jsx', 'json'],
moduleDirectories: ['<rootDir>/node_modules', '<rootDir>/src'],
moduleNameMapper: {
'\\.(css|less)$': '<rootDir>/node_modules/prism-jest/src/styleMock.js',
'^actions\\/([^\\.]*)$': '<rootDir>/src/actions/$1',
'^components\\/([^\\.]*)$': '<rootDir>/src/components/$1',
'^containers\\/([^\\.]*)$': '<rootDir>/src/containers/$1',
'^globals\\/([^\\.]*)$': '<rootDir>/src/globals/$1',
'^hocs\\/([^\\.]*)$': '<rootDir>/src/hocs/$1',
'^i18n\\/([^\\.]*)$': '<rootDir>/src/i18n/$1',
'^utils\\/([^\\.]*)$': '<rootDir>/src/utils/$1'
},
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text', 'json-summary'],
reporters: [
'default',
[
'<rootDir>/node_modules/prism-jest/src/CoverageThreshold.js',
{ coverageThresholdFile: './config/jest/coverageThreshold.json' }
]
],
bail: true
};