当我运行npm run test时,我得到了以下错误
jest-haste-map: Haste module naming collision: {{name}}
The following files share their name; please adjust your hasteImpl:
* <rootDir>/packages/some-package/templates/js/package.json
* <rootDir>/packages/some-package/templates/ts/package.json我的jest.config看起来像
module.exports = {
collectCoverage: true,
setupFiles: ['<rootDir>/jest.setup.js'],
preset: 'ts-jest',
testEnvironment: 'jsdom',
collectCoverageFrom: [
'<rootDir>/packages/**/__tests__/**/*.ts',
'!<rootDir>/packages/**/templates/**/*.ts',
],
testMatch: [
'<rootDir>/packages/**/*.test.ts'
],
transform: {
'^.+\\.js?$': '<rootDir>/node_modules/babel-jest'
},
testPathIgnorePatterns: [
'/node_modules/',
],
coveragePathIgnorePatterns: [
'/node_modules/',
],
projects: [
'<rootDir>/packages/*/jest.config.js'
]
};不确定警告是什么,以及如何修复它。
发布于 2020-04-12 20:50:53
我得到这个警告是因为我的根目录和build目录中存在package.json。通过在我的package.json中添加以下内容,我指定只希望Jest在src中查找测试,从而摆脱了它:
"jest": {
"roots": ["src"]
}https://stackoverflow.com/questions/56635795
复制相似问题