tnrich/vscode-extension-open-cypress

No support for NPM projects?

LazaroOnline opened this issue · 7 comments

It is not compatible with NPM projects.
It only seems to work with Yarn managed projects.

Im using npm and getting this error:
yarn : The term 'yarn' is not recognized as the name of a cmdlet, function, script file, or operable program.

@LazaroOnline whoops good catch there. I didn't think twice about that because I pretty much entirely use yarn instead of npm. I just published a fix to use npm by default

Let me know if that works for you

Sorry, the command still won't work as it is now:
npm run cypress open --config testFiles=${currentlyOpenTabfilePath}
It would only work if you happen to have a script in package.json with that name, which I don't.

You can fix it by changing the command to be like this:
./node_modules/.bin/cypress open --config testFiles="${currentlyOpenTabfilePath}"

as per cypress docs at:
https://docs.cypress.io/guides/guides/command-line.html#How-to-run-commands

Also you have to wrap the filename with double quotes "" to prevent errors, otherwise you have a command injection vulnerability, for example with a file name like:
"test; calc;.js"
will open the calc in windows right after closing the cypress app.

@LazaroOnline thanks for the help :)

Also you have to wrap the filename with commas to prevent errors, otherwise you have a command injection vulnerability, for example with a file name like:
"test; calc;.js"
will open the calc in windows right after closing the cypress app.

What should that look like in the example code?

@LazaroOnline I've implemented your first suggestion

I meant double quotes, I updated the previous comment.
The fix would be like above:
./node_modules/.bin/cypress open --config testFiles="${currentlyOpenTabfilePath}"

Also notice that in the last commit you wrote open twice: open open

I've implemented your suggestion @LazaroOnline . Thanks!