percy / percy-cypress

Visual testing with Cypress and Percy
https://percy.io
MIT License
340 stars 41 forks source link

Doesn't run on Windows "Error: spawn cypress ENOENT" #57

Closed mattmazzola closed 5 years ago

mattmazzola commented 5 years ago

Executing the command npx percy exec -- cypress run --spec "cypress/integration/*" fails on when running locally on Windows but runs successfully on CircleCI linux VM so that's why I'm guessing it's OS dependent.

Output:

E:\Repos\cra-typescript-cypress [master ≡ +0 ~3 -0 !]> npx percy exec -- cypress run --spec "cypress/integration/*"
npx: installed 1 in 1.954s
The "path" argument must be of type string. Received type undefined
E:\Repos\cra-typescript-cypress\node_modules\@percy\agent\bin\run
[percy] created build #5: https://percy.io/conversationlearner/test/builds/1541219
[percy] percy has started.
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn cypress ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:217:19)
    at onErrorNT (internal/child_process.js:394:16)
    at process._tickCallback (internal/process/next_tick.js:174:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:223:12)
    at onErrorNT (internal/child_process.js:394:16)
    at process._tickCallback (internal/process/next_tick.js:174:19)

Versions:

"cypress": "3.1.4",
"@percy/cypress": "1.0.2"

Windows 10 Pro 10.0.17763 Build 17763

Robdel12 commented 5 years ago

Hey Matt! Thanks for opening an issue, I'm going to give this a whirl on my Windows machine today to see if I can uncover what's going on here.

Robdel12 commented 5 years ago

Alright, what is going on here is really subtle. Could you give this a try and see if it works for you?

npx percy exec -- cypress.cmd run --spec "cypress/integration/*"

That worked for me locally and it's what we have to do in our node scripts with example apps to support windows: https://github.com/percy/example-percy-cypress/pull/23/files#diff-5768af5deda587912dcade757b171d20R8

mattmazzola commented 5 years ago

Sorry it took so long to follow up.

I confirmed that using cypress.cmd instead of cypress worked / does not produce the error. Although can you explain why/how this change works?

I thought the cypress command was using the commands exposed by the cypress package and am not sure how adding .cmd would have an affect. I'm assume something to do with the way --exec parameter is written?

Robdel12 commented 5 years ago

Going to close this one up. We released a new version of both this SDK & the underlying SDK (@percy/agent) that removes the need to specify .cmd for Windows: https://github.com/percy/percy-agent/pull/175

What's happening is nodes spawn ignores windows PATHEXT which is kinda like $PATH & that means spawn only works on Windows for .exe files. There's a little more information in the PR linked above.