jscutlery/devkit

`import '@jscutlery/cypress-harness/support';` causes Webpack Compilation Error with Angular 17

abaran30 opened this issue · 1 comments

When setting up Cypress Harness according to the documentation in a project with Angular 17, E2E tests fail to run with the following error:

  Running:  app.cy.ts                                                                       (1 of 1)
Oops...we found an error preparing this test file:

  > src/support/e2e.ts

The error was:

Error: Webpack Compilation Error
Module not found: Error: Package path ./dist/zone is not exported from package...
...

We noticed that removing import '@jscutlery/cypress-harness/support'; from cypress/support/e2e.ts allows the tests to prepare and run again.

Furthermore (maybe a separate and unrelated issue), we are unable to do import { getPreprocessorConfig } from '@jscutlery/cypress-harness/preprocessor-config'; because of error Cannot find module '@jscutlery/cypress-harness/preprocessor-config' or its corresponding type declarations.ts(2307).

Issue reproducible here.

Steps to reproduce:

  • Checkout repository
  • git checkout cypress-13-harness
  • npm ci (if fails, try with --legacy-peer-deps)
  • Attempt npx nx run my-app-a-e2e:e2e - will fail with the aforementioned error

I believe this is because Angular 17 uses zone.js 0.14.0, which has a breaking change as noted here.

The proper way to import zone.js and zone.js/testing is:

import 'zone.js';
import 'zone.js/testing';