-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom location of cypress.config.ts crash on spec update in component tests #26400
Comments
Uh oh - I think you are right, the fix in #25861 (fixes one issue) introduced another. We should be able to calculate the |
Yep, thanks @nikolayeasygenerator, routing this to the CT team |
what would be a potential workaround for this? |
Good question... ideally we'd rewrite this part to not have that issue:
You can also customize the |
@lmiller1990 I am using an nx workspace, where they are providing this function. It also customizes the |
For now we worked around this by creating a symlink to the config file in the root folder |
Not sure - it might be because this code is only called on save, not initial startup.
It definitely uses this plugin during initial bundling, but I suspect some part of the plugin is only called on save/hot reload, not startup. Hm... Is this actually a bug in Cypress, or in the Nx integration? Should we be patching the Nx plugin? |
Getting this bug as well after upgrading to NX/Angular 16 with a dedicated NX library for component tests. It seems to be duplicating the path if we set an absolute path to the The error shows that it's duplicating the path to
Here's my cypress config: import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
import { defineConfig } from 'cypress';
import { join } from 'path';
const base = nxComponentTestingPreset(__filename);
export default defineConfig({
viewportWidth: 1024,
viewportHeight: 768,
component: {
...base,
video: false,
indexHtmlFile: join(__dirname, './cypress/support/component-index.html'),
devServer: {
...base.devServer,
options: {
...base.devServer.options,
projectConfig: {
...base.devServer.options.projectConfig,
buildOptions: {
...base.devServer.options.projectConfig.buildOptions,
assets: [
'apps/my-app/src/favicon.ico',
'apps/my-app/src/robots.txt',
'apps/my-app/src/assets',
],
styles: ['apps/my-app/src/styles.scss'],
},
},
},
},
},
}); |
@dflor003 what's the minimal reproduction to make an Nx project that exhibits this error? I can spend time fixing it this week if I've got a repro. I'm not an Nx guy yet and it's quite a lot to learn, if you can either shoot me a repo with the error or the commands to make one I can try to fix it. |
Let me see if I can reproduce it in an NX app from scratch. |
By the way, completely forgot to mention, we use Vue in our application so this is definitely not Angular-specific |
Great - if you can post a minimal reproduction, that'd help tremendously. |
I can reproduce it following the structure from the initial issue description so it should probably do the trick |
This is the problem. The obvious issue is how do we know where to look? I wonder if we can create a temporary file, include it in the webpack compilation, then just touch that. |
Actually this is NOT the problem - I tried using a temp file, but now a new issue - still cannot find
Double
|
I fixed it! #27320 |
I have the same issue on Windows. I am using the Cypress 12.17.2. My project is an NX monorepo. I have a Cypress config in each project and the component-index.html file in the workspace's root to reuse it. |
Next release this will be shipped! Finally. |
* chore: move entry for #26400 to fix changelog * add line break
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
The
onSpecsChange
handler in theCypressCTWebpackPlugin
file calculates the location of theindexHtmlFile
based on the project root, not the location of thecypress.config.ts
file.If the config file is located at a location other than the project root, trying to update the spec file while it's opened in the runner results in a crash with an error provided in the logs section below (rarely it doesn't fail on the first attempt but then fails on the second one).
Desired behavior
The
indexHtmlFile
location is calculated based on the location of thecypress.config.ts
file where it's declared. not the project root which may be a completely different pathTest code to reproduce
I cannot provide our project code, however, you can scaffold any component testing structure where the config file is not located in the project root and try to update the spec that's being run by the runner at the moment
For example, our structure is as follows
and
indexHtmlFile
in thecypress.config.ts
file is set tosupport/component-index.html
Cypress Version
12.9.0
Node version
v18.15.0
Operating System
macOS Ventura 13.3
Debug Logs
Error: ENOENT: no such file or directory, utime '/Users/{user}/work/{repo}/support/component-index.html' at utimesSync (node:fs:2061:3) at EventEmitter.CypressCTWebpackPlugin.onSpecsChange (/Users/{user}/Library/Caches/Cypress/12.9.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/webpack-dev-server/dist/CypressCTWebpackPlugin.js:70:13) at EventEmitter.emit (node:events:513:28) at EventEmitter.emit (node:domain:489:12) at EventEmitter. (/Users/{user}/Library/Caches/Cypress/12.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/dev-server.js:9:21) at EventEmitter.emit (node:events:513:28) at EventEmitter.emit (node:domain:489:12) at process. (/Users/{user}/Library/Caches/Cypress/12.9.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22) at process.emit (node:events:513:28) at process.emit (node:domain:489:12) at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/{user}/Library/Caches/Cypress/12.9.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40) at emit (node:internal/child_process:937:14) at processTicksAndRejections (node:internal/process/task_queues:83:21)
Other
This issue was actually already reported but discussion stopped: #24398 (comment)

I did some debugging and found the issue at the path
/Users/{user}/Library/Caches/Cypress/12.9.0/Cypress.app/Contents/Resources/app/node_modules/@cypress/webpack-dev-server/dist/CypressCTWebpackPlugin.js
line 70 where the project root (which is always the project root folder wherepackage.json
andpackage-lock.json
are located) and theindexHtmlFile
property in our case isindexHtmlFile: support/component-index.html
are concatenated and the result is/Users/{user}/work/{repo-name}/support/component-index.html
which doesn't exist in our project structureFrom what I gathered, changes done in this PR influence this
The text was updated successfully, but these errors were encountered: