esbuild-jest icon indicating copy to clipboard operation
esbuild-jest copied to clipboard

Adding the --coverage flag throws an error

Open mikealche opened this issue 3 years ago • 2 comments

Hi there!

Thanks for this library! I'm able to run my test suite perfectly without the coverage flag.

But when I add it, it fails. It seems it's not transforming some code: image

This is my jest.config:

const hq = require('alias-hq');

module.exports = {
  collectCoverageFrom: ['./lib/**/*.js', './services/**/*.js'],
  coveragePathIgnorePatterns: ['/services/graphql-api/schema/'],
  setupFiles: [
    '<rootDir>/jest.setup.js',
    require.resolve('core-js/stable'),
    require.resolve('regenerator-runtime/runtime'),
  ],
  testEnvironment: 'node',
  testMatch: [
    '<rootDir>/test/**/*.test.js',
    '<rootDir>/services/**/*.test.js',
    '<rootDir>/test/**/*.test.ts',
    '<rootDir>/services/**/*.test.ts',
  ],
  transform: {
    '^.+\\.js$': ['esbuild-jest'],
    '^.+\\.ts$': ['esbuild-jest'],
  },
  transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$'],
  moduleNameMapper: hq.get('jest'),
};

Any ideas of what could be happening?

Update: the problem was that it was trying to use babel for coverage. I switched it to use v8 and it seems to work.

Thanks!!

mikealche avatar Jun 14 '21 15:06 mikealche

You can try to set jest coverageProvider configuration to v8

mrdulin avatar Feb 09 '22 08:02 mrdulin