Jest-preset-angular: Cannot find module 'zone.js/dist/zone.js' after upgrade to zone.js 0.11.0

Created on 19 Aug 2020  ·  9Comments  ·  Source: thymikee/jest-preset-angular

🐛 Bug Report

 FAIL  file-size.pipe.spec.ts
  ● Test suite failed to run

    Cannot find module 'zone.js/dist/zone.js' from '../../../../../node_modules/jest-preset-angular/build/setupJest.js'

    Require stack:
      /node_modules/jest-preset-angular/build/setupJest.js
      /node_modules/jest-preset-angular/index.js
      src/stubs/setupJest.ts

      at Resolver.resolveModule (../../../../../node_modules/jest-resolve/build/index.js:307:11)

To Reproduce

Steps to reproduce the behavior:

  • upgrade zone.js 0.11.0

envinfo

System:
    OS: MacOS

Npm packages:
    jest: last
    jest-preset-angular: last
    typescript: last
Bug Confirmed obvious

Most helpful comment

@ahnpnl there is still an issue after upgrading to 0.11.1: Cannot find module 'zone.js/dist/zone.js' from 'node_modules/jest-preset-angular/build/setupJest.js'

It should load zone.js/dist/zone, not zone.js/dist/zone.js, because they have changed the build setup.
Same for the proxy file.

All 9 comments

@ahnpnl there is still an issue after upgrading to 0.11.1: Cannot find module 'zone.js/dist/zone.js' from 'node_modules/jest-preset-angular/build/setupJest.js'

It should load zone.js/dist/zone, not zone.js/dist/zone.js, because they have changed the build setup.
Same for the proxy file.

Thanks @ocombe !

There should be a PR to update the usage of zone.js too, which was mentioned in https://github.com/angular/angular/pull/38473#issuecomment-674404753 .

cc @JiaLiPassion

I have the same problem what have mentioned @ocombe

the workaround in the meanwhile is

  • manually copy the content of node_modules/jest-preset-angular/build/setupJest.js to a file in your project

  • adjust all the import for zone.js

  • import that file into your setup jest file

Sorry for the inconveniences, now 0.11.1 is available, I will create a PR to update.

https://github.com/thymikee/jest-preset-angular/blob/master/src/setup-jest.ts#L5

@JiaLiPassion @ahnpnl

correct will be

require('zone.js/dist/zone');

Close via #448

Was this page helpful?
0 / 5 - 0 ratings