question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest-preset-angular v8 has breaking changes

See original GitHub issue

Please make sure you have read the submission guidelines before posting an issue

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I’m reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)

Expected Behavior

Running jest tests does not fail

Current Behavior

Jest tests fail with the following error message:

Module jest-preset-angular/AngularSnapshotSerializer.js in the snapshotSerializers option was not found.

Steps to Reproduce

  1. update jest-preset-angular to 8.0.0
  2. run jest tests

Other

I looked into jest-preset-angular and it seems that they introduced a build folder with v8 thus the path is not correct anymore.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
whimzyLivecommented, Feb 18, 2020

@leon I managed to fix it by changing jest-preset-angular/AngularSnapshotSerializer.js to jest-preset-angular/build/AngularSnapshotSerializer.js and jest-preset-angular/HTMLCommentSerializer.js to jest-preset-angular/build/HTMLCommentSerializer.js.

Since in latest version of jest they have been moved under /build directory. REF: https://github.com/thymikee/jest-preset-angular/releases/tag/v8.0.0

10reactions
ashokshetty1970commented, Dec 17, 2019

in your module, you may have the file jest.config.js with the following content.

module.exports = {
    name: 'name',
    preset: '../../jest.config.js',
    coverageDirectory: '../../coverage/libs/common',
    snapshotSerializers: [
        'jest-preset-angular/AngularSnapshotSerializer.js',
        'jest-preset-angular/HTMLCommentSerializer.js'
    ],
    setupFilesAfterEnv: ["./src/test-setup.ts"]
};

comment or remove the member “snapshotSerializers”. It is not needed. Worked for me, The resulting should be

module.exports = {
    name: 'name',
    preset: '../../jest.config.js',
    coverageDirectory: '../../coverage/libs/common',
   
    setupFilesAfterEnv: ["./src/test-setup.ts"]
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

jest-preset-angular/CHANGELOG.md at main - GitHub
BREAKING CHANGES. js files from node_modules are now compiled with esbuild to improve performance. NodeJs range version support now is ...
Read more >
jest-preset-angular/CHANGELOG.md - UNPKG
jest -preset-angular/CHANGELOG.md ; 278, ## BREAKING CHANGES ; 279 ; 280, * Drop support for Angular < **9.0**, see https://angular.io/guide/releases#support-policy ...
Read more >
jest-preset-angular - npm
A preset of Jest configuration for Angular projects. Build Status NPM Version GitHub license. Our online documentation is available at https:// ...
Read more >
jest-preset-angular | Yarn - Package Manager
BREAKING CHANGES · Since Angular 11, the minimum version of zone. · Now we are using Angular AST transformers, reflect-metadata is not needed...
Read more >
https://raw.githubusercontent.com/thymikee/jest-pr...
[12.2.3](https://github.com/thymikee/jest-preset-angular/compare/v12.2.2...v12.2.3) ... BREAKING CHANGES * **NodeJs** range version support now is `^12.20.0 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found