swc-project / jest

Super-fast alternative for babel-jest or ts-jest without type checking. Please use main repository for issues
757 stars 37 forks source link

jest works fine, but with the coverage flag many tests fail #151

Open ctsstc opened 1 year ago

ctsstc commented 1 year ago

It seems when I just run npx jest everything runs just fine, all the tests pass in record time.

As soon as I try to pass the coverage flag over I get many failures ie: npx jest --coverage.

If I run the test suite that is failing in isolation everything seems to run fine ie: npx jest src/app.module.spec.ts --coverage --collectCoverageFrom=src/app.module.ts

If I remove the collectCoverageFrom flag then it proceeds to fail again ie: npx jest src/app.module.spec.ts --coverage

It seems as if many of the dependencies that are mocked out in a test are not being mocked. If I isolate the coverage collection it seems to be fine, but then it seems that when all the files are gathered for coverage it's causing issues. Is it trying to run the code crawling through the AST instead of through the spec implementation that mocks things out?

ctsstc commented 1 year ago

I just deleted: node_modules, coverage, build.

Ran: npm i, npx jest --clearCache, now for whatever reason it seems I'm able to run npx jest --coverage without issue 🤷😬