esbuild-jest
esbuild-jest copied to clipboard
Adding the --coverage flag throws an error
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:
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!!
You can try to set jest coverageProvider configuration to v8