
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
@angular-builders/jest
Advanced tools
Jest runner for Angular build facade. Allows ng test run with Jest instead of Karma
Allows running ng test with Jest instead of Karma & Jasmine.
The builder comes to provide zero configuration setup for Jest while keeping the workspace clear of boilerplate code.
$ npm remove karma karma-chrome-launcher karma-coverage-istanbul-reporter karma-jasmine karma-jasmine-html-reporter
$ rm ./karma.conf.js ./src/test.ts
jest if you still haven't):
$ npm i -D jest @types/jest @angular-builders/jest
In tsconfig.spec.json (root directory, used by Jest):
jasmine in types array with jesttest.ts entry from files arrayIn tsconfig.json (root directory, used by IDE):
jest to types arraytsconfig.json is the config file that your IDE uses so you have to instruct it explicitly to use Jest typings.angular.json:
"projects": {
"[your-project]": {
"architect": {
"test": {
"builder": "@angular-builders/jest:run",
"options": {
// see below
}
}
}
}
}
ng testThe builder supports multi-project workspaces out of the box, the only thing required is editing tsconfig.spec.json in the relevant project directory as described above.
config - path to jest config file or a Jest configuration object, relative to project root (or src/ directory in case of non-project app), defaults to jest.config.js. Other extensions are also supported. The Jest configuration might be written in TypeScript, but you should explicitly specify the path to the jest.config.ts. The configuration is merged on top of the default configuration, so there is no need to specify the whole jest configuration in this file. Just specify the changes you'd like to make to the default configuration.
You can also provide configuration directly as an object:
"options": {
"config": {
"testTimeout": 10000,
"verbose": true
}
}
The way the configurations are merged is as following:
Thus, if you don't provide config in options, and you'd like to customize the configuration of a single project in your workspace, you only have to add jest.config.js in this project's root directory and specify the configuration delta in this file.
Or, if you'd like the same custom configuration to be applied to all the projects in the workspace, you just specify it in package.json. Another option in such a case is creating a single config file in the workspace root and specifying it in angular.json for each project.
tsConfig - path to tsconfig file. If the path is relative then it is evaluated relative to the project root. Defaults to tsconfig.spec.json that is located in project root.
zoneless - boolean (default: true).
true (default): For Angular 21+ applications using zoneless change detection (the new Angular default)false: For applications that rely on zone.js automatic change detectionBREAKING CHANGE in v21: Previous versions always used zone.js. If your app uses zone.js change detection, set zoneless: false:
"options": {
"zoneless": false
}
globalMocks - array (default: ["matchMedia"]).
Only matchMedia is supported as jsdom still doesn't implement window.matchMedia.
BREAKING CHANGE in v21: The styleTransform, getComputedStyle, and doctype mocks have been removed as Jest 30's jsdom now supports these natively.
If you need custom browser API mocks, add your own setup file via setupFilesAfterEnv in your jest config.
[jest-cli-option] - any option from Jest CLI options. For example, to run unit tests without caching and with junit-reporter use:
"options": {
"no-cache": true,
"reporters": "jest-junit"
}
These options can also be provided directly to ng test command. For example, to run a single test from this suite:
describe('My cool suite', () => {
it('Should do one thing', () => {
// do something...
});
it('Should do another thing', () => {
// do something...
});
});
Use the following command: ng test --test-name-pattern="My cool suite Should do one thing"
Notice that for array-like arguments you should use , delimiter instead of space delimiter. These are limitations of Angular CLI.
Thus, if you want to provide multiple arguments to find-related-tests option you should be passing it like this:
$ ng test --find-related-tests file1,file2
Note: For multi-project workspaces, paths must be relative to the workspace root, not the project root:
$ ng test my-lib --find-related-tests projects/my-lib/src/lib/service.ts,projects/my-lib/src/lib/component.ts
Use this for automatic migration of your Jasmine tests to Jest framework.
Please find below a selection of potential issues you might face when using this builder. Refer to jest-preset-angular Troubleshooting for jest-preset-angular specific issues.
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.
One of the recommendations might require you to transpile js files through babel-jest.
In this case make sure you add allowSyntheticDefaultImports to the ts-jest configuration (see here for an explanation of this setting).
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
allowSyntheticDefaultImports: true,
},
],
}
Your final jest.config.js file should look something like this:
const esModules = ['[thir-party-lib]'].join('|');
module.exports = {
transformIgnorePatterns: [`<rootDir>/node_modules/(?!${esModules})`],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
allowSyntheticDefaultImports: true,
},
],
'^.+\\.js$': 'babel-jest',
},
};
FAQs
Jest runner for Angular build facade. Allows ng test run with Jest instead of Karma
The npm package @angular-builders/jest receives a total of 142,449 weekly downloads. As such, @angular-builders/jest popularity was classified as popular.
We found that @angular-builders/jest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.