简体   繁体   English

JavaScript - jest-haste-map:Haste 模块命名冲突:{{name}}

[英]JavaScript - jest-haste-map: Haste module naming collision: {{name}}

I'm getting the following error when I run npm run test :运行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

My jest.config looks like我的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'
  ]
};

Not sure what the warning is, and how I can fix it.不确定警告是什么,以及如何修复它。

I got this warning as a result of package.json existing in my root directory and in my build directory.由于package.json存在于我的根目录和我的build目录中,我收到了这个警告。 I was able to get rid of it by specifying that I only want Jest to look for tests in src by adding the following to my package.json:通过将以下内容添加到我的 package.json 中,我能够通过指定我只希望 Jest 在src查找测试来摆脱它:

  "jest": {
    "roots": ["src"]
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM