Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

istanbul ignore file is not working #76

Open
Hideman85 opened this issue Jul 13, 2022 · 2 comments
Open

istanbul ignore file is not working #76

Hideman85 opened this issue Jul 13, 2022 · 2 comments

Comments

@Hideman85
Copy link

Hideman85 commented Jul 13, 2022

I just switched from ts-jest to esbuild-jest and I have some files that should not be included in the coverage but are 馃
My files have a /* istanbul ignore file */ first line comment and should be ignored.
May I know if I miss a config somehow?

// jest.config.cjs
module.exports = {
  transform: {
    '^.+\\.ts$': [
      'esbuild-jest',
      {
        sourcemap: 'external'
      }
    ]
  },
  testEnvironment: 'node',
  collectCoverageFrom: [
    'src/**/*.{js,ts}',
    '!src/**/*.d.ts', //  Ignore types file
  ],
  coverageReporters: ['json', 'text', 'text-summary'],
  coverageThreshold: {
    global: {
      lines: 89,
      statements: 89,
    },
  },
};

EDIT: The reason is esbuild remove all comments evanw/esbuild#516

@gwsbhqt
Copy link

gwsbhqt commented Mar 2, 2023

@Hideman85 I have a similar problem, have you found a solution?

@gwsbhqt
Copy link

gwsbhqt commented Mar 7, 2023

I solved this problem because the translation of esbuild removes redundant comments, causing the ignored comments to be deleted. There is such a solution in esbuild to force the retention of comments. E.g:

https://esbuild.github.io/api/#legal-comments

before:
/* istanbul ignore file */

after:
/* istanbul ignore file -- @preserve */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants