🌐
GitHub
github.com › thymikee › jest-preset-angular › blob › main › CHANGELOG.md
jest-preset-angular/CHANGELOG.md at main · thymikee/jest-preset-angular
February 27, 2026 - Drop support for Angular 11, 12 · Jest 29 is required · destroyAfterEach and teardown are no longer available to use, please use testEnvironmentOptions instead. target is tsconfig is now respected according to user configuration, it is no longer hardcoded at ES2015. See also note at https://thymikee.github.io/jest-preset-angular/docs/getting-started/installation ·
Author   thymikee
🌐
npm
npmjs.com › package › jest-preset-angular
jest-preset-angular - npm
1 week ago - A preset of Jest configuration for Angular projects.
      » npm install jest-preset-angular
    
Published   May 07, 2026
Version   16.1.5
Discussions

[Bug]: npm install fails with latest jest 29.0.3
Version 2.2.2 Steps to reproduce 1,Use jest 29.0.3 as dependency with latest jest-preset-angular 2.2.2 2, npm install fails ERESOLVE unable to resolve dependency tree Expected behavior npm install ... More on github.com
🌐 github.com
35
September 15, 2022
Newest 'jest-preset-angular' Questions - Stack Overflow
Stack Overflow | The World’s Largest Online Community for Developers More on stackoverflow.com
🌐 stackoverflow.com
jestjs - Angular 14 and Jest (cannot run tests) - Stack Overflow
I am upgrading Angular version in my project to 14. But when I tried to run unit tests, I get the same error for all of them: ● Test suite failed to run Cannot find module '@angular/core/tes... More on stackoverflow.com
🌐 stackoverflow.com
typescript - Configure Jest for Angular - Stack Overflow
According to various guides on the web configuring Jest for Angular is as easy as this: ng new jest-test cd jest-test npm i -D jest jest-preset-angular Modify package.json: "test": "jest", [...] ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › thymikee › jest-preset-angular
GitHub - thymikee/jest-preset-angular: Jest configuration preset for Angular projects. · GitHub
A preset of Jest configuration for Angular projects.
Starred by 916 users
Forked by 304 users
Languages   TypeScript 89.7% | JavaScript 7.1% | CSS 2.8%
🌐
Thymikee
thymikee.github.io › presets
Presets | jest-preset-angular
3 weeks ago - In Jest, presets are pre-defined configurations that help streamline and standardize the process of setting up testing environments.
🌐
Thymikee
thymikee.github.io › installation
Installation | jest-preset-angular
April 13, 2026 - For ESM configuration, please see more in details with ESM guide. In your project root, create a setup file with following contents: ... Adjust scripts part your package.json to use jest instead of ng, e.g. ... jest-preset-angular uses JSDOM which is different from normal browsers.
🌐
GitHub
raw.githubusercontent.com › thymikee › jest-preset-angular › master › CHANGELOG.md
https://raw.githubusercontent.com/thymikee/jest-pr...
* `target` is `tsconfig` is now respected according to user configuration, it is no longer hardcoded at `ES2015`. See also note at https://thymikee.github.io/jest-preset-angular/docs/getting-started/installation # [13.0.0-next.1](https://github.com/thymikee/jest-preset-angular/compare/v13.0.0-next.0...v13.0.0-next.1) (2023-01-27) ### Features * support Jest 29 ([#1937](https://github.com/thymikee/jest-preset-angular/issues/1937)) ([b0b57a7](https://github.com/thymikee/jest-preset-angular/commit/b0b57a7df09fe3d84baccdc4f032ffbb9235bb69)), closes [#1774](https://github.com/thymikee/jest-preset-a
🌐
GitHub
github.com › thymikee › jest-preset-angular › issues › 1774
[Bug]: npm install fails with latest jest 29.0.3 · Issue #1774 · thymikee/jest-preset-angular
September 15, 2022 - ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: xxx@3.0.1 npm ERR! Found: jest@29.0.3 npm ERR! node_modules/jest npm ERR! dev jest@"29.0.3" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer jest@"^28.0.0" from jest-preset-angular@12.2.2 npm ERR!
Author   qwertyuiopzxcvbnmlkjhgfdsa1
🌐
Stack Overflow
stackoverflow.com › questions › tagged › jest-preset-angular
Newest 'jest-preset-angular' Questions - Stack Overflow
Today I've started using Jest to UnitTest some of our TypeScript files within our Angular project. After the initial Jest setup was done, creating a test for a pure TypeScript method in our util.ts ... ... Using ng-mocks 13.5.2 with jest-preset-angular 12 and @ngneat/spectator 11 I am getting the below error any time I try to use MockComponents or MockPipe in my spec file.
🌐
Medium
medium.com › @abhijit_chikane › set-up-jest-in-angular-v20-project-zoneless-replace-karma-jasmine-5ddd5552f2cb
Set Up Jest in Angular(v20+) Project (Zoneless, Replace Karma & Jasmine) | by Abhijit Chikane | Medium
September 3, 2025 - This ensures zoneless testing works properly in your Angular app. Tell TypeScript to use Jest types instead of Jasmine: ... import type { Config } from 'jest'; const config: Config = { preset: 'jest-preset-angular', setupFilesAfterEnv: ['<rootDir>/src/setup-jest.ts'], testPathIgnorePatterns: [ '<rootDir>/node_modules/', '<rootDir>/dist/', ], }; export default config;
Find elsewhere
🌐
npm
npmjs.com › package › @angular-builders › jest
angular-builders/jest
January 14, 2026 - This means that the library you're using doesn't use commonjs module format (which jest expects to see). You will need to implement the recommendations mentioned in jest-preset-angular Troubleshooting Guide.
      » npm install @angular-builders/jest
    
Published   Jan 14, 2026
Version   21.0.3
🌐
DEV Community
dev.to › fransaoco › how-to-set-up-jest-in-angular-19-step-by-step-guide-1c2p
How to Set Up Jest in Angular 19 (Step-by-Step Guide) - DEV Community
April 21, 2025 - #angular #jest #npm · npm install jest jest-preset-angular @types/jest --save-dev · jest: Core testing framework. jest-preset-angular: Adds Angular support for Jest. @types/jest: TypeScript definitions for Jest. npm remove karma karma-chrome-launcher karma-jasmine karma-coverage karma-jasmine-html-reporter ·
🌐
Thymikee
thymikee.github.io › angular >=13
Angular >=13 | jest-preset-angular
April 9, 2026 - Angular 13 introduces ESM package format for Angular packages. jest-preset-angular currently supports testing with Jest in CommonJS mode with Angular 13 using default preset.
🌐
GitHub
github.com › thymikee › jest-preset-angular › issues
Issues · thymikee/jest-preset-angular
Jest configuration preset for Angular projects. Contribute to thymikee/jest-preset-angular development by creating an account on GitHub.
Author   thymikee
Top answer
1 of 2
2

UPDATE:

The most important change was to configure the transformIgnorePatterns as below:

"transformIgnorePatterns": [
    "/node_modules/@protontech/(?!jsmimeparser).+\\.js$"
],

I recreated a project with angular 19, then changed the jest.config.ts to reflect what was provided in the jest-preset-angular latest documentation.

import type { Config } from 'jest';
import presets from 'jest-preset-angular/presets';

export default {
...presets.createCjsPreset({
    tsconfig: 'tsconfig.spec.json',
}),
setupFilesAfterEnv: ['<rootDir>/src/setup-jest.ts'],
    "transformIgnorePatterns": [
        "/node_modules/@protontech/(?!jsmimeparser).+\\.js$"
    ],
} satisfies Config;

Then we can update the setup-jest.ts as below:

import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
// import './jest-global-mocks';

setupZoneTestEnv();

Also adding tsconfig.spec.json for reference:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": ["jest", "node"]
  },
  "files": ["polyfills.ts"],
  "include": ["**/*.spec.ts", "**/*.d.ts"]
}

Github Repo -> npm i --legacy-peer-deps -> npx jest --verbose (You can try your normal test command instead of this)


Seems like you are using a JS file and during conversion (Read as typescript) it is throwing an error, could you try:

import type {Config} from 'jest';

const config: Config = {
    verbose: true,
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
    "transformIgnorePatterns": [
      "node_modules/(?!@protontech)"
    ],
    moduleNameMapper: {
        '^src/(.*)$': '<rootDir>/src/$1',
        '^app/(.*)$': '<rootDir>/src/app/$1',
        '^assets/(.*)$': '<rootDir>/src/assets/$1',
        '^environments/(.*)$': '<rootDir>/src/environments/$1',
    },
};

Jest gives an error: "SyntaxError: Unexpected token export"

2 of 2
0

This configuration should resolve the "Unexpected token export" error:

import type { Config } from 'jest';

const config: Config = {
    verbose: true,
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
    moduleNameMapper: {
        '^src/(.*)$': '<rootDir>/src/$1',
        '^app/(.*)$': '<rootDir>/src/app/$1',
        '^assets/(.*)$': '<rootDir>/src/assets/$1',
        '^environments/(.*)$': '<rootDir>/src/environments/$1',
    },
    transformIgnorePatterns: [
        // This line tells Jest to transform the jsmimeparser module
        'node_modules/(?!@protontech/jsmimeparser)'
    ],
    transform: {
        '^.+\\.(ts|js|html)$': [
            'jest-preset-angular',
            {
                tsconfig: '<rootDir>/tsconfig.spec.json',
                stringifyContentPathRegex: '\\.(html|svg)$',
            },
        ],
    },
};

export default config;

Make sure your tsconfig.spec.json includes the necessary compiler options for handling ES modules:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  }
}
🌐
GitHub
github.com › thymikee › jest-preset-angular › issues › 1838
Angular 15 Support · Issue #1838 · thymikee/jest-preset-angular
November 17, 2022 - Just creating this for tracking. Per: The leftover work now includes: Adopt changes from ts-jest 29 Migrate any config under globals to be transformer config, just like ts-jest Test with angular 15 Originally posted by @ahnpnl in #1774 (...
Author   michaelfaith
🌐
Thymikee
thymikee.github.io › troubleshooting
Troubleshooting | jest-preset-angular
April 8, 2026 - Reference: https://github.com/angular/material2/issues/7101 · This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it is published to npm as uncompiled source files. Here's what you can do. A typical Jest error is like this:
🌐
Reddit
reddit.com › r/angular › jest failing in angular project: persistent "cannot find module canvas.node" despite mocking
r/angular on Reddit: Jest Failing in Angular Project: Persistent "Cannot find module canvas.node" Despite Mocking
April 11, 2025 -

Hi everyone,

I'm struggling with a persistent Jest error in my Angular (v19) project running on macOS with pnpm, and I'm hoping someone might have encountered this before or have fresh ideas.

The Problem:

When I run pnpm jest, my tests fail immediately with:

FAIL src/app/app.component.spec.ts
● Test suite failed to run

Cannot find module '../build/Release/canvas.node'

What I've Tried (Exhaustively):

I know the standard solution is to mock the canvas module, but it's not working. Here's everything I've done:

  1. Mocking via moduleNameMapper:

    • Added the following to jest.config.js:

      module.exports = {
          preset: 'jest-preset-angular', 
          setupFilesAfterEnv: ['<rootDir>/src/setup.jest.ts'],
          moduleNameMapper: {
              '^canvas$': '<rootDir>/__mocks__/canvas.mock.js', 
              '^src/(.*)$': '<rootDir>/src/$1',
          },
      };
    • Created __mocks__/canvas.mock.js in the project root:

      module.exports = {}; 
  2. Confirmed canvas is NOT a direct dependency: It's not listed in package.json.

  3. Installed System Dependencies: Ran brew install pkg-config cairo pango libpng jpeg giflib librsvg on macOS.

  4. Reinstalled Dependencies: Ran rm -rf node_modules, pnpm install after installing system deps.

  5. Cleared Caches: Used pnpm jest --clearCache and also cleared pnpm cache (pnpm cache clean) during deep clean.

  6. Explicit Mock in Setup: Added jest.mock('canvas', () => ({}), { virtual: true }); to src/setup.jest.ts.

  7. Forced Newer jsdom: Used pnpm overrides in package.json to force jsdom: "^22.1.0" and reinstalled.

  8. Deep Clean & Verbose Install: Did rm -rf node_modules, rm pnpm-lock.yaml, pnpm cache clean, then pnpm install --verbose.

Despite all this, the exact same error persists.

Relevant Versions:

  • Angular: 19.x

  • Jest: 29.7.0

  • jest-preset-angular: 14.5.4

  • jest-environment-jsdom: 29.7.0 (inferred)

  • canvas (transitive): 3.1.0 (inferred)

  • jsdom (transitive): 20.0.3 (inferred)

  • OS: macOS

  • Package Manager: pnpm

Has anyone run into a situation where moduleNameMapper seems completely ignored for a transitive dependency loaded by jsdom? Any ideas what else could be interfering or alternative approaches I could try? Could it be a weird interaction between pnpm, Jest 29, and this older jsdom/canvas combo?

Thanks in advance for any suggestions!

🌐
Medium
medium.com › @philip.mutua › setting-up-jest-in-your-angular-16-project-3638ef65f3a3
Setting Up Jest in Your Angular Project | by Philip Mutua | Medium
December 10, 2024 - In your angular application locate the karma.config.js file your angular project has these two files delete them. ... To kickstart your enhanced testing experience, begin by installing the required dependencies using your preferred package manager · # Using Yarn yarn add -D jest jest-preset-angular @types/jest # Using npm npm install -D jest jest-preset-angular @types/jest