romanresh / vscode-testcafe

This extension allows you to run TestCafe tests directly from VS Code
https://marketplace.visualstudio.com/items?itemName=romanresh.testcafe-test-runner
MIT License
47 stars 15 forks source link

Error running single test - cannot read property 'fsPath' of undefined #33

Closed jafin closed 5 years ago

jafin commented 5 years ago

I've come back to a testcafe project after a while. And previously had the testcafe runner working well. But today when attempting to run a single test from vsCode the below error is logged:

VSCode 1.35 TestCafe Runner 1.4.5 Typescript 3.5 TestCafe 1.2

[info] ExtensionService#loadCommonJSModule c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\json-language-features\client\dist\jsonMain [2019-06-11 08:41:16.784] [exthost] [error] TypeError: Cannot read property 'fsPath' of undefined at context.subscriptions.push.vscode.commands.registerCommand.args (c:\Users\user\.vscode\extensions\romanresh.testcafe-test-runner-1.4.5\out\src\extension.js:47:48) at d._executeContributedCommand (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:498:463) at d.$executeContributedCommand (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:498:838) at d._doInvokeHandler (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:644:1006) at d._invokeHandler (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:644:698) at d._receiveRequest (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:643:346) at d._receiveOneMessage (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:642:141) at define.constructor._protocol.onMessage.e (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions

jafin commented 5 years ago

Not sure if this is the correct approach, but I edited the plugin and replaced each usage of args (which was null)

   context.subscriptions.push(
        vscode.commands.registerCommand('testcaferunner.runTestFileInChromium', args => {
            controller.startTestRun("chromium", args.fsPath, "file");
        })
    );

to

  context.subscriptions.push(
        vscode.commands.registerCommand('testcaferunner.runTestFileInChromium', () => {
            controller.startTestRun('chromium', vscode.window.activeTextEditor.document.fileName, 'file');
        }),
    );

If this is correct, I can submit a patch.

romanresh commented 5 years ago

Hi @jafin . Please, try to update VS Code to the latest 1.35.1 version. I have this one and I could not reproduce the issue. The 'args' parameter should be the URI object if a command is called from the file explorer's context menu.

If VSCode update doesn't help, please check a list of installed extensions. I'm not sure that some extension can change this behavior (extensions must be black-boxed), but who knows...

jafin commented 5 years ago

@romanresh When I launch "Run tests in Chrome" from the command palette, there are 2 entries for "TestCafe: Run Test(s) in Chrome". One does work, the other does not and returns the error described above, I think the command that fails is defined as

{
                "command": "testcaferunner.runTestFileInChrome",
                "title": "TestCafe: Run Test(s) in Chrome"
},

From the context menu it works fine. So perhaps my misuse of triggering from the command palette Perhaps just my misuse of the command palette