briebug / jest-schematic

Angular schematic for adding Jest and the required files to an Angular CLI project
MIT License
322 stars 37 forks source link

test replacing ts-jest with @swc-node/jest #49

Closed sod closed 1 year ago

sod commented 3 years ago

We don't use this package, but we use jest & angular and maybe you are interested.

We replaced ts-jest with @swc-node/jest. Cold cache jest went from 60s to 7s.

swc is a typescript to javascript compiler that also supports annotations & metadata export, thus works with angular jit. swc is written in rust and is ~70x faster as typescript. So by using it you eliminate the compile overhead and are mostly left running the tests themself.

using swc-jest as a jest transformer is pretty straight forward, this is our transform block in jest.config.js

    transform: {
        '\\.ts$': [
            require.resolve('@swc-node/jest'),
            {
                target: 'es2018',
                module: 'commonjs',
                experimentalDecorators: true,
                emitDecoratorMetadata: true,
                dynamicImport: true,
                sourcemap: true,
            },
        ],
    }
lamelyan commented 1 year ago

@sod Is there an Angular project that is using @swc-node/jest? Could you provide a link?

rene-leanix commented 1 year ago

@lamelyan, I stumbled upon @sod's example repo for this. It does not include Zone.js yet.

sod commented 1 year ago

I gonna close as won't do. I have no time right now to contribute a PR.