vscode-testcafe icon indicating copy to clipboard operation
vscode-testcafe copied to clipboard

when use the context menu to run a single e2e file, got an error

Open chaiyilin opened this issue 7 years ago • 8 comments

got Error: ENOENT: no such file or directory, open 'c:\alinta\testDemo\node_modules\testcafe\client\hammerhead.js'

this file does not exist

chaiyilin avatar Nov 16 '17 21:11 chaiyilin

Hi @chaiyilin . Which version of testcafe do you use? And do you have the testcafe package installed in the working directory (c:\alinta\testDemo)?

romanresh avatar Nov 17 '17 05:11 romanresh

"testcafe": "^0.18.3", and yes, i install it locally

chaiyilin avatar Nov 17 '17 05:11 chaiyilin

Hm, I just checked it with the [email protected] and it works correctly on my local machine.

Try to remove the c:\alinta\testDemo\node_modules folder and install it again: call npm install in the c:\alinta\testDemo directory.

If it doesn't help set the Uncaught Exception checkbox (on the Debug tab) and rerun a test. Which file tries to find the hammerhead.js file in the wrong folder? If the VS Code's debugger doesn't stop on this exception, check also the All Exceptions checkbox on the Debug tab of VS Code and run your test again.

romanresh avatar Nov 17 '17 07:11 romanresh

I can reproduce this issue and found a workaround.

Visual Studio Code 1.19.2

TestCafe Test Runner 1.4.1

$ node --version
v8.9.4

$ npm --version
5.6.0

$ npx testcafe --version
0.18.6

using the plugin

tleveil@DEV-PC1-MV MINGW64 ~/workspace/mv-workflow-ui (test)
$ cd "c:\Users\tleveil\workspace\mv-workflow-ui" ; node --no-deprecation --inspect-brk=38384 "node_modules\testcafe\lib\cli\index.js" chrome "c:\Users\tleveil\workspace\mv-workflow-ui\tests\profile-menu.test.js" --fixture pro
file-menu
Debugger listening on ws://127.0.0.1:38384/1637b468-9e21-4c15-afcf-5ce53dfd88a9
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
ERROR Cannot prepare tests due to an error.

Error: ENOENT: no such file or directory, open 'c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\client\hammerhead.js'
    at readSync (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\read-file-relative\index.js:24:22)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\lib\testcafe.js:23:27)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\lib\index.js:166:17)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe-vue-selectors\lib\index.js:13:17)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\tests\profile-menu.test.js:2:1)

Type "testcafe -h" for help.
Waiting for the debugger to disconnect...

reproducing without the plugin

tleveil@DEV-PC1-MV MINGW64 ~/workspace/mv-workflow-ui (test)
$ cd "c:\Users\tleveil\workspace\mv-workflow-ui" ; node --no-deprecation "node_modules\testcafe\lib\cli\index.js" chrome "c:\Users\tleveil\workspace\mv-workflow-ui\tests\profile-menu.test.js" --fixture profile-menu
ERROR Cannot prepare tests due to an error.

Error: ENOENT: no such file or directory, open 'c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\client\hammerhead.js'
    at readSync (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\read-file-relative\index.js:24:22)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\lib\testcafe.js:23:27)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe\lib\index.js:166:17)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\node_modules\testcafe-vue-selectors\lib\index.js:13:17)
    at Object.<anonymous> (c:\Users\tleveil\workspace\mv-workflow-ui\tests\profile-menu.test.js:2:1)

Type "testcafe -h" for help.

workaround

If we pass a relative test file path instead of absolute, it runs fine with npx.

tleveil@DEV-PC1-MV MINGW64 ~/workspace/mv-workflow-ui (test)
$ cd "c:\Users\tleveil\workspace\mv-workflow-ui" ; node --no-deprecation "node_modules\testcafe\lib\cli\index.js" chrome ".\tests\profile-menu.test.js" --fixture profile-menu
testing app at http://localhost:8080
 Running tests in:
 - Chrome 63.0.3239 / Windows 10 0.0.0

 profile-menu
 √ personne n'est connecté
 √ connexion et déconexion de Jean Tartempion


 2 passed (6s)

thomasleveil avatar Jan 19 '18 09:01 thomasleveil

Hi @thomasleveil . I met this error a few times and fixed it via full reinstalling of testcafe (via deleting node_modules, package-lock.json and executing npm i). So, this problems looks like a problem in the installation of the testcafe package and its dependencies.

How did you find relation between a relative/absolute path to a test file and this problem?

romanresh avatar Feb 08 '18 10:02 romanresh

@chaiyilin Have you resolved the error? Did you try to reinstall testcafe?

romanresh avatar Feb 08 '18 10:02 romanresh

reinstalling testcafe did not help in my case. I guess the issue is in testcafe

thomasleveil avatar Feb 08 '18 17:02 thomasleveil

Hi @thomasleveil,

I faced with the same problem a few times. It seems it relates to some npm unexpected behavior. Usually it is fixed by reinstalling modules (via npm or yarn). Meanwhile we'll investigate why it happens and let you know if we have any results.

AlexanderMoskovkin avatar Feb 16 '18 08:02 AlexanderMoskovkin