Im using Visual Studio Code, and Im trying to debug Jest tests inside of a Nrwl.Nx workspace for Angular.
Here is what I've tried so far:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All Tests",
"program": "${workspaceFolder}/src/Web/Finance/client-app/node_modules/.bin/jest",
"args": ["--runInBand"],
"cwd": "${workspaceFolder}/src/Web/Finance/client-app/apps/finance",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/src/Web/Finance/client-app/node_modules/jest/bin/jest"
}
}
]
}
app.component.spec.ts
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import 'zone.js/dist/zone.js';
import 'zone.js/dist/async-test.js';
import 'zone.js/dist/proxy.js';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
});
Originally, I ran the app.component.spec.ts test without importing anything from zone.js/dist, but when I would run the debugger in VS Code, I would get this:
Failed: "Zone is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/zone.js"
So I imported the zone.js/dist files you see in app.component.spec.ts
Now when I run the debugger in VS Code, I get this:
Expected to be running in 'ProxyZone', but it was not found.
at Function.Object.<anonymous>.ProxyZoneSpec.assertPresent (../../node_modules/zone.js/dist/proxy.js:42:19)
at runInTestZone (../../node_modules/zone.js/dist/async-test.js:202:23)
at Object.<anonymous> (../../node_modules/zone.js/dist/async-test.js:168:17)
Doing internet searches has not provided me any information about how to troubleshoot this error.