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 file paths need updated

See original GitHub issue

Describe the bug jest-preset-angular have moved files around in their v9 release. setup-jest should now be imported from jest-preset-angular/setup-jest instead of jest-preset-angular/build/setup-jest

The import of setup-jest here needs an additional tryCatch block for the new file location/name https://github.com/storybookjs/storybook/blob/next/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts#L21

This bug prevents storyshots from running with jest v27 and jest-preset-angular v9

To Reproduce jest-preset-angular >9

System Environment Info:

System: OS: macOS 10.15.7 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Binaries: Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.17.0/bin/yarn npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm Browsers: Chrome: 91.0.4472.77 Firefox: 88.0.1 Safari: 14.1.1 npmPackages: @storybook/addon-a11y: 6.2.9 => 6.2.9 @storybook/addon-actions: 6.2.9 => 6.2.9 @storybook/addon-essentials: 6.2.9 => 6.2.9 @storybook/addon-links: 6.2.9 => 6.2.9 @storybook/addon-postcss: 2.0.0 => 2.0.0 @storybook/addon-storyshots: 6.2.9 => 6.2.9 @storybook/addon-storysource: 6.2.9 => 6.2.9 @storybook/angular: 6.2.9 => 6.2.9

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
Mickeiikcommented, Jul 13, 2021

Don’t know if someone forked the project but I managed to make things work by using jest config’s moduleNameMapper to override the paths :

moduleNameMapper : {
    'jest-preset-angular/build/setupJest': 'jest-preset-angular/setup-jest',
    'jest-preset-angular/build/AngularSnapshotSerializer': 'jest-preset-angular/build/serializers/ng-snapshot',
    'jest-preset-angular/build/HTMLCommentSerializer': 'jest-preset-angular/build/serializers/html-comment'
}
1reaction
shilmancommented, Jun 10, 2021

I would recommend somebody releases a forked version of storyshots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
jestjs - How to setup tsconfig paths in jest.config.js. Angular 8 ...
You can have several paths for @shared in tsconfig.json , one for the index.ts and others for sub-paths:
Read more >
jest-preset-angular - npm
In your project root, create setup-jest.ts file with following contents: import 'jest-preset-angular/setup-jest';. Add the following section:.
Read more >
Install Jest for Angular - Medium
npm install jest jest-preset-angular --save-dev ... You can now remove the karma.conf.js and test.ts files. ... Config file paths. You can get this:...
Read more >
jest-preset-angular | Yarn - Package Manager
Now we are using Angular AST transformers, reflect-metadata is not needed anymore. Jest 28 correctly resolves Angular package format files so the ng-jest- ......
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