I've been experiencing slow test runs in my Nx Angular 10 repository, so I made the decision to switch from using jest-ts to @swc/jest.
jest.presets.ts
const nxPreset = require('@nrwl/jest/preset');
module.exports = {
...nxPreset,
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'html', 'js', 'json'],
testEnvironment: 'jsdom',
transform: {
['.+\\.js$']: 'babel-jest',
'^.+\\.(ts|html)$': '@swc/jest',
},
}
.swcrc
{
"jsc": {
"target": "es2020",
.
.
.
The component is a brand new Angular component with no additional logic, and the failing test looks like this:
describe('SpeedTestComponent', () => {
let component: SpeedTestComponent;
let fixture: ComponentFixture<SpeedTestComponent>;
.
.
.
Upon running the test, it throws the following error https://i.sstatic.net/d2Cmc.png
This issue only arises with TestBed tests.
The expected behavior is for the test to pass.
packages
"@swc/core": "^1.2.152",
"@swc/helpers": "^0.3.6",
"@swc/jest": "^0.2.20",
"jest": "^26.2.2",