Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 576
Kousha Avatar asked Jun 17 '19 16:06

Kousha


1 Answers

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"]
  }
like image 183
jmcumb Avatar answered Nov 26 '22 22:11

jmcumb