Socket
Socket
Sign inDemoInstall

jest-preset-angular

Package Overview
Dependencies
2
Maintainers
3
Versions
134
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-preset-angular

Jest preset configuration for Angular projects


Version published
Maintainers
3
Created

Package description

What is jest-preset-angular?

jest-preset-angular is a Jest preset configuration for Angular projects. It simplifies the setup and configuration of Jest for testing Angular applications, providing necessary configurations, transformers, and environment settings.

What are jest-preset-angular's main functionalities?

Setup and Configuration

This feature provides a preset configuration for Jest, making it easier to set up Jest in Angular projects. The code sample shows how to configure Jest to use jest-preset-angular in the Jest configuration file.

module.exports = { preset: 'jest-preset-angular', setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'] };

Transformers

jest-preset-angular includes transformers to handle TypeScript and Angular templates. The code sample demonstrates how to configure Jest to use ts-jest for transforming TypeScript and HTML files.

module.exports = { transform: { '^.+\.(ts|html)$': 'ts-jest' } };

Global Mocks

jest-preset-angular provides global mocks for common Angular dependencies, such as Angular's testing utilities. The code sample shows how to import jest-preset-angular to include these global mocks in your tests.

import 'jest-preset-angular';

Other packages similar to jest-preset-angular

Changelog

Source

8.4.0 (2021-03-04)

Features

  • add ngcc-jest-processor util script (#853) (e8c9689)

DEPRECATIONS

  • Import serializer via 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js' is deprecated in favor of 'jest-preset-angular/build/serializers/no-ng-attributes'
  • Import serializer via 'jest-preset-angular/build/AngularSnapshotSerializer.js' is deprecated in favor of 'jest-preset-angular/build/serializers/ng-snapshot'
  • Import serializer via 'jest-preset-angular/build/HTMLCommentSerializer.js' is deprecated in favor of 'jest-preset-angular/build/serializers/html-comment'
  • Import setup file via import 'jest-preset-angular' is deprecated in favor of import 'jest-preset-angular/setup-jest'

Readme

Source

Jest Preset Angular

A preset of Jest configuration for Angular projects.

Build Status NPM Version NPM Version GitHub license

This is a part of the article: Testing Angular faster with Jest.

Getting Started

These instructions will get you setup to use jest-preset-angular in your project. For more detailed documentation, please check online documentation.

Install using yarn:

yarn add -D jest jest-preset-angular

Or npm:

npm install -D jest jest-preset-angular

Configuration

In your project root, create setup-jest.ts file with following contents:

import 'jest-preset-angular/setup-jest';

Add the following section:

  • to your root jest.config.js
// jest.config.js
module.exports = {
  preset: 'jest-preset-angular',
  setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};
  • or to your root package.json
{
  "jest": {
    "preset": "jest-preset-angular",
    "setupFilesAfterEnv": ["<rootDir>/setup-jest.ts"]
  }
}

Built With

Authors/maintainers

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

FAQs

Last updated on 04 Mar 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc