I switched my NX/angular project from webpack to esbuild by setting
"serve": {
"executor": "@nx/angular:dev-server",
...
...
in the project.json of the NX package.
After that the corresponding -e2e package failed to run with the following output:
...
chunk-JTPYGZ63.js | profile-routes | 82.50 kB | 12.77 kB
...and 132 more lazy chunks files. Use "--verbose" to show all the files.
➜ Local: http://localhost:4200/
➜ press h + enter to show help
Running: xyz.cy.ts (2 of 43)
Oops...we found an error preparing this test file:
> src/support/e2e.{js,ts}
The error was:
Error: Webpack Compilation Error
Module not found: Error: Can't resolve '/Users/...-e2e/src/support/e2e.{js,ts}' in...
but the file /Users/...-e2e/src/support/e2e.ts exists
My cypress.config.ts looks like this
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
...
return {
...nxE2EPreset(__filename),
// supportFile: 'src/support/e2e.ts', IF THIS IS UNCOMMENTED IT WORKS
};
},
}
});
So if I overwrite the supportFile and change the {js,ts} syntax to .ts it works.
What am I doing wrong. There seems to be something with the nxE2EPreset I am missing to work with esbuild.