最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jestjs - JavaScript - jest-haste-map: Haste module naming collision: {{name}} - Stack Overflow

programmeradmin11浏览0评论

I'm getting the following error when I run 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

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'm getting the following error when I run 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

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.

Share Improve this question edited Jun 17, 2019 at 16:58 rmlan 4,6572 gold badges22 silver badges28 bronze badges asked Jun 17, 2019 at 16:56 KoushaKousha 36.2k59 gold badges186 silver badges313 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 19

I got this warning as a result of package.json existing in my root directory and in my build directory. 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:

  "jest": {
    "roots": ["src"]
  }
发布评论

评论列表(0)

  1. 暂无评论