Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing export build from package.json in v9.0.0 #935

Closed
NicolasTsc opened this issue May 28, 2021 · 14 comments · Fixed by #936
Closed

missing export build from package.json in v9.0.0 #935

NicolasTsc opened this issue May 28, 2021 · 14 comments · Fixed by #936
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@NicolasTsc
Copy link

Hi I just updated the jest-preset-angular version and now receive another error when trying to run example tests.

🐛 Bug Report

File not found: jest-preset-angular/build/InlineFilesTransformer (resolved as: C:\Users___\Documents\frontend\jest-preset-angular\build\InlineFilesTransformer)

To Reproduce

Steps to reproduce the behavior:

Run ng test

Expected behavior

Tests should run

Link to repo (highly encouraged)

https://github.com/NicolasTsc/jest-angular

Error log:


  ● Test suite failed to run

    File not found: jest-preset-angular/build/InlineFilesTransformer (resolved as: C:\Users\___\Documents\frontend\jest-preset-angular\build\InlineFilesTransformer)

      at ConfigSet.resolvePath (node_modules/ts-jest/dist/config/config-set.js:444:19)
      at node_modules/ts-jest/dist/config/config-set.js:225:46
          at Array.map (<anonymous>)
      at resolveTransformers (node_modules/ts-jest/dist/config/config-set.js:223:37)
      at ConfigSet._setupConfigSet (node_modules/ts-jest/dist/config/config-set.js:233:137)
      at new ConfigSet (node_modules/ts-jest/dist/config/config-set.js:142:14)
      at NgJestTransformer.TsJestTransformer._createConfigSet (node_modules/ts-jest/dist/ts-jest-transformer.js:111:16)
      at NgJestTransformer.TsJestTransformer._configsFor (node_modules/ts-jest/dist/ts-jest-transformer.js:89:34)
      at NgJestTransformer.TsJestTransformer.getCacheKey (node_modules/ts-jest/dist/ts-jest-transformer.js:172:28)
      at ScriptTransformer._getCacheKey (node_modules/@jest/transform/build/ScriptTransformer.js:280:41)


System:
OS: Windows 10

Npm packages:
jest: 27.0.1
jest-preset-angular: 9.0.0
typescript: 4.2.4

@NicolasTsc NicolasTsc added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 28, 2021
@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

Please check this comment #925 (comment)

@ahnpnl ahnpnl closed this as completed May 28, 2021
@ahnpnl ahnpnl added Not An Issue Not jest-preset-angular issue and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 28, 2021
@NicolasTsc
Copy link
Author

If I understand the changelog correctly I have to add snapshotSerializers by adding
const jestPresetAngularSerializers = require('jest-preset-angular/build/serializers')
at the top of the jest.config.js and inside the module.exports
snapshotSerializers: jestPresetAngularSerializers,.

When I try to run the test I receive the error
An unhandled exception occurred: Package subpath './build/serializers' is not defined by "exports" in

Is there anything I missed from the changelog?

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

You can omit entirely snapshotSerializers and use only preset: 'jest-preset-angular'

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

The error about An unhandled exception occurred: Package subpath './build/serializers' is not defined by "exports" in is a valid error because missing export for build.

Example config is here https://github.com/thymikee/jest-preset-angular/blob/master/examples/example-app-v12/jest.config.js

@ahnpnl ahnpnl reopened this May 28, 2021
@ahnpnl ahnpnl added 🐛 Bug Confirmed Bug is confirmed and removed Not An Issue Not jest-preset-angular issue labels May 28, 2021
@ahnpnl ahnpnl changed the title Jest 27 still not working with version 9.0.0 missing export build from package.json in v9.0.0 May 28, 2021
@NicolasTsc
Copy link
Author

Okay thanks for clarifying. The error occures when using the example config too.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

I see your jest config in your repo is already migrated correctly :)

ahnpnl added a commit that referenced this issue May 28, 2021
@NicolasTsc
Copy link
Author

Thanks for fixing it so quickly. How can I get the new changes?

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

should be fixed now with 9.0.1

@NicolasTsc
Copy link
Author

I now have the error:
``
● Test suite failed to run

File not found: jest-preset-angular/build/InlineFilesTransformer 

``

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

that file doesn't exist anymore in v9.0.0 you need to remove it from your jest config. It is mentioned in CHANGELOG.

Also make sure to clear Jest cache via jest --clearCache so that new changes are always applicable.

@NicolasTsc
Copy link
Author

Yeah this file isn`t reference in my jest config. I tried clearing the cache and deleted / reinstalled my node_modules but the problem stays. You can check my repo for the jest-config. I also tried it with another repository but have the same error unfortunately

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

The current version of @angular-builder/jest doesn't support v9.0.0 . Please follow this just-jeb/angular-builders#913

In summary, if you are using @angular-builder/jest, you cannot use Jest 27 and jest-preset-angular 9.0.0 :)

@NicolasTsc
Copy link
Author

Do I need to use @angular-builder/jest? I need Jest 27 to import some modules I couldn`t import before.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 28, 2021

In your repo, if you replace "test": "ng test" by "test": "jest" to bypass @angular-builder/jest, it will work.

@angular-builder/jest is a way to execute Jest with ng test. It is not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants