forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Describe debugging in VS Code (DevExpress#1358)
* Describe debugging via VS Code * Restructure debugging docs * Merge the debugging description back in one topic
- Loading branch information
1 parent
374cd3a
commit 9b3e7cb
Showing
10 changed files
with
211 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
docs/articles/documentation/recipes/debugging-with-chrome-dev-tools.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
layout: docs | ||
title: Debugging with Chrome Developer Tools | ||
permalink: /documentation/recipes/debugging-with-chrome-dev-tools.html | ||
--- | ||
# Debugging with Chrome Developer Tools | ||
|
||
Starting with version 6.3.0, Node.js allows you to debug applications in Chrome Developer Tools. | ||
If you have Chrome and an appropriate version of Node.js installed on your machine, | ||
you can debug TestCafe test code. | ||
To do this, add the `--inspect` and `--debug-brk` flags to the test run command. | ||
|
||
```sh | ||
testcafe --inspect --debug-brk chrome ./tests | ||
``` | ||
|
||
Put the `debugger` keyword in test code where you want to stop. | ||
|
||
```js | ||
fixture `My fixture` | ||
.page `https://devexpress.github.io/testcafe/example`; | ||
|
||
test('My test', async t => { | ||
debugger; | ||
await t | ||
.click('#populate') | ||
.click('#submit-button'); | ||
}); | ||
``` | ||
|
||
After the test run command is executed, a debugging URL will appear in the console. | ||
|
||
![Console with a debugging URL](../../images/debugging/server-debugging-console.png) | ||
|
||
Open this URL in a new Chrome instance. Chrome will invoke its Developer Tools and the debugger will stop test execution at the first line. | ||
Click the 'Resume script execution' button or press F5 to continue. After that, text execution will pause at the `debugger` keyword allowing you to debug test code. | ||
|
||
![Chrome Developer Tools](../../images/debugging/server-debugging-chrome.png) |
56 changes: 56 additions & 0 deletions
56
docs/articles/documentation/recipes/debugging-with-visual-studio-code.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
layout: docs | ||
title: Debugging with Visual Studio Code | ||
permalink: /documentation/recipes/debugging-with-visual-studio-code.html | ||
--- | ||
# Debugging with Visual Studio Code | ||
|
||
Before debugging in Visual Studio Code, ensure that your root test directory contains a `package.json` file that includes `testcafe` in the `devDependencies` section. | ||
|
||
```json | ||
{ | ||
"devDependencies": { | ||
"testcafe": "x.y.z" | ||
} | ||
} | ||
``` | ||
|
||
where `x.y.z` is the TestCafe version you use. | ||
|
||
Then you need to install TestCafe locally in the tests directory via `npm`. | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
The next step is adding a launch configuration that runs TestCafe tests. See the [Visual Studio Code documentation](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) to learn how to create a configuration. | ||
|
||
You will need to add the following configuration to the `launch.json` file. | ||
|
||
```json | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch test files with TestCafe", | ||
"program": "${workspaceRoot}/node_modules/testcafe/bin/testcafe.js", | ||
"args": [ | ||
"firefox", | ||
"${file}" | ||
], | ||
"cwd": "${workspaceRoot}" | ||
} | ||
``` | ||
|
||
This configuration contains the following attributes: | ||
|
||
* `type` - specifies the type of the configuration. Set to `node` for a Node.js configuration. | ||
* `request` - specifies the request type. Set to `launch` since this configuration launches a program. | ||
* `name` - specifies the name of the configuration. | ||
* `program` - path to a JS file that will be executed. In this case, it is the TestCafe module. | ||
* `args` - [command line arguments](../using-testcafe/command-line-interface.md) passed to the launched program. In this case, they specify the browser in which the tests should run and the test file. | ||
* `cwd` - the current working directory. Set to the workspace root. | ||
|
||
Save the `launch.json` file. The new configuration will appear in the configuration drop-down. | ||
|
||
Now you can open a file with TestCafe tests, select the configuration you have just created and click the Run button. | ||
Tests will run with the debugger attached. You can put breakpoints in test code and the debugger will stop at them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
docs/articles/documentation/test-api/client-side-debugging.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.