firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Jest runner throws zonejs missing error after updating to Angular v16 #332

Open mal90 opened 11 months ago

mal90 commented 11 months ago

We use vscode-jest-runner in our angular project. Since we updated angular to v16, getting this error

   ......
   Formatters › .booleanFormatter

    zone-testing.js is needed for the fakeAsync() test helper but could not be found.
            Please make sure that your environment includes zone.js/testing

      at resetFakeAsyncZone (node_modules/@angular/core/fesm2022/testing.mjs:249:11)
      at Object.<anonymous> (node_modules/@angular/core/fesm2022/testing.mjs:27123:13)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 21 skipped, 22 total
Snapshots:   0 total
Time:        3.578 s

image

As a fix, below 2 zonejs related import statements are added to the root jest setup config, and since this issue was resolved

import 'zone.js';
import 'zone.js/testing';

image

However i was wondering is there a way we can fix this issue without having to change the setup config, within the jest-runner extension itself?

domsleee commented 11 months ago

Hi, I think the scope of this extension is to make jest run by invoking the jest command.

It feels like having behaviour in the extension where the config automatically imports zone.js from the local package would be out of scope.

I think configs per frameworks like angular can be in separate repos like this one: https://github.com/thymikee/jest-preset-angular