Working within a NX mono repo, I am running component tests for an Angular app using Cypress. However, I keep encountering an error in the cypress app that occurs when a test reruns after making changes to the testing code:
Your configFile threw an error from: cypress.config.js
We stopped running your tests because your config file crashed.
Searching the repo for a cypress.config.js
file only yields cypress.config.ts
files, as the entire NX repo is TypeScript-based.
The content of my cypress.config.ts file is as follows:
import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
export default defineConfig(nxComponentTestingPreset(__filename));
I attempted to resolve the issue by modifying the configuration like this:
import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
export default defineConfig({
component: {
... nxComponentTestingPreset(__filename),
devServer: {
... nxComponentTestingPreset(__filename).devServer,
options: {
projectConfig: {
... nxComponentTestingPreset(__filename).devServer.options.projectConfig,
root: 'apps/angular-app'
}
}
}
},
});
However, this change did not resolve the problem.
The stack trace error is showing strange behavior by duplicating file paths. It's doubling the path to the component-index.html
file:
Error: ENOENT:
no such file or directory, utime '/Users/USER/projects/frontends/apps/angular-app/Users/USER/projects/frontends/apps/angular-app/cypress/support/component-index.html' at utimesSync (node:fs:2047:3)
Could it be related to using a newer version of Angular? When launching the Cypress testing app with
USER@machine angular-app % npx cypress open
, I receive the following warning:
Warning: Component Testing Mismatched Dependencies
We detected that you have versions of dependencies that are not officially supported:
@angular/platform-browser-dynamic. Expected ^=13.0.0 || ^=14.0.0 || ^=15.0.0, found 16.0.1. If you're experiencing problems, downgrade dependencies and restart Cypress.
Blockquote