-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Error: EINVAL: invalid argument, mkdir on windows for cypress + windows + Angular project #8599
Comments
Can you please try the latest Cypress version v5.2.0, Cypress v3 is a really old version. |
Having the same issue using version 5.0.0 |
Tested version 5.2.0, issue not resolved |
@andreilaptev1 Thank you for confirmation, I was going to test using mentioned version EOD, I will skip then. It looks like issue is due to |
@pavandixit93 probably yes. The weird thing is Mac users do not face this issue in our app. |
Please could you create an example repo showing this problem that we can look at? |
Once I create an example repo, it works fine.
The issue is Cypress does not work on our company app, and I may not share code.
Thinking it might has something to do with internal setup, but not sure
|
Solution found: |
@andreilaptev1 Thanks for the workaround, its working now. But is there any side effect if i set When i tried by setting |
@pavandixit93 yep, I've seen that. In this case, code doesn't recognize functions from imported modules. So far having no answer, will continue investigation. Should you find a solution first, please share |
Could you include the code from your support.js file? Seems like the issue may be coming from something inside that. Thanks! |
@jennifer-shehane We dont have import 'cypress-axe';
import './commands'; And in import * as axe from 'axe-core';
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
Cypress.Commands.add('injectAxe', () => {
cy.window({ log: false }).then(window => {
window.axe = axe;
});
});
addMatchImageSnapshotCommand({
failureThreshold: 0.05,
failureThresholdType: 'percent',
customDiffConfig: { threshold: 0.05 },
capture: 'viewport'
});
Cypress.Commands.overwrite('matchImageSnapshot', (originalFn, subject, name, options) => {
if (Cypress.browser.isHeadless) {
return originalFn(subject, name, options);
}
return cy.log('No screenshot taken when headed');
}); |
We even do not have this code, just import './commands';
import '@cypress/code-coverage/support'; Later this .ts file is being recompiled to .js and put into /dist folder |
Currently we are facing the same issue on windows. We are using cypress 5.0.0 and node 12.18.3 |
I am able to reproduce this by setting a relative Setup Reproduction steps
Expected: Cypress visits cypress.io page Notes: |
We found a workaround for this issue: Create nested/cypressSupportForWindows.js file with content: import '../support/index'; and then change nested/cypress.json to point that file “supportFile”: “cypressSupportForWindows.js”, |
I have the same issue. My project configuration requires to point supportFile as relative path |
I have the same problem. plugins\index.js /**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
const webpack = require("@cypress/webpack-preprocessor");
const options = {
webpackOptions: require("@vue/cli-service/webpack.config.js"),
watchOptions: {}
};
module.exports = (on, config) => {
on("file:preprocessor", webpack(options));
return Object.assign({}, config, {
fixturesFolder: "cypress/fixtures",
integrationFolder: "cypress/integration",
screenshotsFolder: "cypress/screenshots",
videosFolder: "cypress/videos",
supportFile: false
});
}; cypress.json {
} package.json {
"name": "uitesting_cypress",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",
"test:components": "vue-cli-service test:components",
"uitest": "vue-cli-service serve & cypress open"
},
"dependencies": {
"@types/uuid": "^8.3.1",
"axios": "^0.24.0",
"core-js": "^3.6.5",
"open": "^8.4.0",
"uuid": "^8.3.2",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.2.0",
"vuetify": "^2.4.0"
},
"devDependencies": {
"@cypress/vue": "*",
"@cypress/webpack-dev-server": "^1.7.0",
"@cypress/webpack-preprocessor": "^5.10.0",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-typescript": "^7.0.0",
"@vue/test-utils": "^1.0.3",
"cypress": "^9.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"typescript": "~4.1.5",
"vue-cli-plugin-cypress-experimental": "~1.2.0",
"vue-cli-plugin-vuetify": "~2.4.3",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.0"
}
} |
I had the same problem with a NX mono repo. In our case, it was caused by having |
I had the same problem. In my case I could fix it by renaming the root folder of my project. It had spaces in the folder name represented at %20. When I changed the %20 to actual spaces in the fole name, it started to work. |
I got the same error for a project with the root at
I suspect that Cypress or Webpack concatenates paths in a wrong way - two absolute paths were joined according to the error message. Is it possible to print a stacktrace to find out who calls the This information isn't available even after setting the environment variable
|
I managed to track the issue to this part of the code: cypress/packages/server/lib/plugins/preprocessor.js Lines 72 to 78 in a5ec234
If for some reason the test file is not part of the project root, then this code will fail to remove the base path of the spec file (when it is bundled by webpack and copied to cypress work folder), I think that by default the project root is based on the location of the cypress config file, or based on where you ran the cli command to start it. To fix that, just set the config option |
This issue still occurs on Windows. It can be reproduced by putting support files or spec files outside of the project root directory. |
I think that this problem can be reproduced on any platform. I reproduced it on If you decide to maintain dependencies and configuration of your E2E tests separate from your build directory, you will face the bug described by this issue. A workaround: create a symlink to the test and source files inside the Cypress directory, and use the symlink in the Cypress configuration. Cypress will see everything apparently inside its directory and will work well.
EDITED: The problem occurs only on Windows. |
@prantlf I tried to reproduce on MacOS and Linux using your information: I put my support file outside my project directory, but it still loads. I did not try windows yet. Am I understanding this correctly? |
The same happend with us. The identical setup (support file outside project) worked on linux and macOS, but it did not work on Windows. |
Oh, I'm sorry, @lmiller1990. The problem occurred on Windows only. I tried the workaround @ocombe pointed out, but it didn't help me. It's been some time and I can't remember the details any more. The Cypress configuration is in the project root in cypress-test-tiny:
My project has Cypress completely separated from the build:
|
I will help you fix this but trying to reproduce the issue based on snippets and comments is a bit time consuming, can you please upload a repo I can clone and reproduce the issue? That will let me spend more time finding a fix. Thanks! |
Can be reproduced with the following repo: /~https://github.com/ausi/cypress-issue-8599 git clone git@github.com:ausi/cypress-issue-8599.git
cd cypress-issue-8599
cd subdirectory
npm install
npx cypress run This results in the following output (only on Windows):
|
Thank you! |
We are experiencing the same issue on Windows. |
I am not able to allocate bandwidth to fix this one right now. I'd recommend using a work around in the meantime, unless you are able to contribute a fix. |
Ran into this problem yesterday after splitting up our codebase into two repos. After much experimentation with Structure:
Example symlink command:
|
Has anyone tried using Windows WSL? |
I suspect that you'd have to use the headless mode only. You wouldn't be able to use Cypress in the windows mode. I tried configuring X.Org once and using an X-Server on Windows. Not with Cypress, but with Chrome and VS Code. The convenience of the work was a lot worse than with the native Windows applications. Since WSL2 was released, the performance of the filesystem has improved and the remote features too. But not UI. WSL wasn't designed for running UI applications. |
Never mind, it should work well since it's a cross-platform tool. In my case, I have a project with two NPM workspaces, like a monorepo. It works flawlessly on Mac and Linux, but this week a colleague found this error on Windows. |
Ok, the symlink worked for me. But since I have to keep the project working on Mac and Linux, I've decided to do some more work. This is my project structure today using npm workspaces: ├── cypress I added a file called setup-symlinks.js on root to create the symlinks: const fs = require("fs");
const path = require("path");
function createSymlink(target, path) {
try {
if (!fs.existsSync(path)) {
fs.symlinkSync(target, path, "junction");
console.log(`Created symlink: ${path} -> ${target}`);
} else {
console.log(`Symlink already exists: ${path}`);
}
} catch (err) {
console.error(`Error creating symlink: ${err.message}`);
}
}
if (process.platform === "win32") {
const projectRoot = path.resolve(__dirname);
const e2ePath = path.join(projectRoot, "cypress");
const cypressOneLink = path.join(projectRoot, "cypress-one", "cypress");
const cypressTwoLink = path.join(projectRoot, "cypress-two", "cypress");
createSymlink(e2ePath, cypressOneLink);
createSymlink(e2ePath, cypressTwoLink);
} else {
console.log("No symlinks needed on this OS.");
} Added a script to package-json (also on root): "scripts": {
"postinstall": "node setup-symlinks.js"
}, Updated both config files with dynamic configuration of specs and support folders (for cross-platform compatibility): ...
e2e: {
specPattern:
process.platform === "win32"
? "cypress/e2e/**/*.cy.js"
: "../cypress/e2e/**/*.cy.js",
supportFile:
process.platform === "win32"
? "cypress/support/index.js"
: "../cypress/support/index.js",
... And (I didn't know that), but the symlink folders should be added to .gitignore:
Updated readme for Windows users
I hate this solution, but is better than using a Windows WSL, Docker, or any virtual machine approach. And I feel bad this problem occurs since always (or Cypress version 3). |
I'm starting to take a look into this issues. Just some updates since this is a pretty old issue.
I am still exploring solutions, but I am leaning towards making parent files bundle to the root of the bundle directory so the preprocessor can output correctly to a path. Collisions could be possible, but I think they are highly unlikely. |
I believe this is fixed in #30067. I have tested the built binary |
Seems that this binary file you provided fixes the issue on our end. Thanks! |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
When cypres@3.8.3 is run on windows in Angular project, i am getting this type of error when i click on any test specs and try to run and capture image snapshot:
Error: EINVAL: invalid argument, mkdir 'C:\Users\rocks\AppData\Roaming\Cypress\cy\production\projects\styleguide-e2e-a8ba09f50d81ec188e3b12528503dca9\bundles\C:\Users\rocks\project\torque\styleguide\cypress\support
Cypress cache folder is:
C:\Users\rocks\AppData\Roaming\Cypress\cy\production\projects
for windows.Desired behavior:
It should not throw any error on windows system.
Test code to reproduce
Package.json
NPM command to open cypress:
The text was updated successfully, but these errors were encountered: