Closed Bogs-123 closed 1 year ago
@Bogs-123 this looks like you're importing angular modules within the Cypress e2e suit which is will not understand as that runs in a node js context not the browser.
Can you add the reproducible to a git repo instead of a zip file?
Also what kind of library are you generating, I assume it's an angular library since you're getting an error about unable to compile angular mjs files.
@barbados-clemens
Added a repo
The imported library is a standard library created with the NX extension in Visual Studio Code.
@Bogs-123 Looks like you created an angular library from the @nx/angular
plugin.
You're running into this issue because you're main index.ts
exports an angular module along with your variable. When importing from the index.ts
file all things within that file are evaluated which means the angular module is trying to be loaded within nodejs environment for cypress, hence the error you're seeing.
I'd recommend making a library with @nx/js
to house your runtime agnostic code like the variables you showed then you can import that @nx/js
library inside the e2e project and the angular project.
Alternatively you can make a secondary entry point within the tsconfig.base.json
that exports another file that only contains the non angular code, But importing FE code like angular inside cypress e2e isn't something supported.
personally I would make a new library.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Importing a library into a cypress test file breaks the app.
Expected Behavior
Cypress e2e tests can import from libraries.
GitHub Repo
Failing Cypress Test
Steps to Reproduce
Small reproduction: testing-fails.zip
Notice the import in app.cy.ts from @org/core. Remove that import makes test runnable.
Nx Report
Failure Logs
Operating System
Additional Information
No response