Broken Storyshots with latest jest-preset-angular due to setupJest module being renamed to setup-jest on ^8.3.0
See original GitHub issueDescribe the bug
The jest-preset-angular
library has a breaking change (and the only one that I’ve come across) introduced on its v8.3.0
release. They’ve renamed the setupJest
file to setup-jest
.
This loader storybook/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts
is requiring setupJest
.
To Reproduce Steps to reproduce the behavior:
Use the latest storyshots
with "jest-preset-angular": "^8.3.0"
, run jest
and you’ll get the following
Cannot find module 'jest-preset-angular/build/setupJest' from 'node_modules/@storybook/addon-storyshots/dist/frameworks/angular/loader.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:307:11)
at requireActual (node_modules/@storybook/addon-storyshots/dist/frameworks/angular/loader.js:32:10)
at Object.setupAngularJestPreset [as load] (node_modules/@storybook/addon-storyshots/dist/frameworks/angular/loader.js:38:5)
at Object.load [as default] (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:26:19)
at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/api/index.js:60:14)
Expected behavior
The tests should run normally.
Screenshots N/A
Code snippets N/A
System: N/A
Additional context N/A
Please let me know if it’s alright to raise a PR for this.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Storybook Addon StoryShots for Angular 12 - Stack Overflow
Since jest-preset-angular version 9, setup-jest.ts is no longer located into jest-preset-angular/build/ folder (and this is not the only impacted file).
Read more >jest-preset-angular | Yarn - Package Manager
Getting Started. These instructions will get you setup to use jest-preset-angular in your project. For more detailed documentation, please check online ...
Read more >Cannot find module '@angular/core/testing' - You.com
Cannot find module '@angular/core/testing' from 'node_modules/jest-preset-angular/build/setup-jest.js. app references appear to be fine.
Read more >Storyshots is unable to run tests using Angular 12 ... - Issuehunt
//setup-jest.ts import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/ ...
Read more >Angular >=13 | jest-preset-angular - GitHub Pages
0.0, jest-preset-angular introduces a few extra changes to be able to run Jest with Angular 13: moduleFileExtensions is updated to include mjs files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can also map the modules until this is fixed in your jest.config.js:
I got the same error while following the official guide Learn Storybook.
● Test suite failed to run