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

Unable to run testcafe from visual studio code #35

Open rehanmomin opened 5 years ago

rehanmomin commented 5 years ago

Unable to run testcafe from visual studio code

Installed TestCafe Test Runner 1.4.5 from market Place .

nothing is happening in Visual Studio Code. No error is shown nothing.

Same program is running from Visual Studio Code Powershell.

romanresh commented 5 years ago

Hi @rehanmomin . Try to open any JS/TS file in your workspace and check the VS Code context menu. It should contain a few "TestCafe: ..." items.

rehanmomin commented 5 years ago

@romanresh sorry to not include this in previous comment. But after Clicking TesCafe: Run in (any browser) Nothing is happening.

Now i have updated TestCafe Test Runner to 2.0.0

romanresh commented 5 years ago

@rehanmomin It's difficult to find out a cause of this problem without debugging. Let me describe you some background, how the extension works.

The extension uses the Terminal tab to run the testcafe process. When you click the "TestCafe: ..." menu item the extension determines a test name in your file (based on cursor position) and run the testcafe process in terminal with parameters (including filename and test name).

Usually the extension cannot run a test because of a few known problems:

  1. It cannot determines test name by the cursor position. In this case you will see the VSCode error message. The extension uses regular expression to find a nearest test and its name to the cursor.
  2. The testcafe process returns a error (if test name determined incorrectly or the extension passed wrong parameters to the testcafe process). In this case you will see the error in the Terminal tab of VS Code.

If nothing happens (both terminal is empty and no VSCode message box appears) you can try to find the cause of the problem yourself via debugging of the extension:

  1. clone this repository
  2. run npm i to install dependencies
  3. open the folder in VS Code
  4. set a breakpoint somewhere here: https://github.com/romanresh/vscode-testcafe/blob/fc02df30c517dbb5276a697a50e591f14c9cc709/src/extension.ts#L258
  5. press F5 to start debugging. It will run a new experimental instance of VSCode with overwritten version of the extension and attached debugger.
  6. in the runned experimental version of VS code open a folder with your testcafe tests and try to run any test via the extension (using a context menu). The debugger should stop on your breakpoint and you will be able to debug the extension.