Skip to content

Commit 1bc04a0

Browse files
authored
docs: using DEBUG=pw:api (microsoft#2578)
1 parent 1c7a895 commit 1bc04a0

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

docs/intro.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
- [Usage](#usage)
66
- [First script](#first-script)
77
- [System requirements](#system-requirements)
8+
- [TypeScript IDE support](#typescript-ide-support)
89
- [Debugging scripts](#debugging-scripts)
10+
* [Using editor debugger](#using-editor-debugger)
11+
* [Verbose logging](#verbose-logging)
912
<!-- GEN:stop -->
1013

1114
<br>
@@ -80,17 +83,57 @@ Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):
8083
* **macOS**: Requires 10.14 or above.
8184
* **Linux**: Depending on your Linux distribution, you might need to install additional
8285
dependencies to run the browsers.
86+
* Firefox requires Ubuntu 18.04+
8387
* For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),
8488
which is based on Ubuntu.
8589

8690
<br>
8791

92+
## TypeScript IDE support
93+
94+
Playwright comes with built-in support for TypeScript. Playwright type definitions will be imported automatically.
95+
96+
It is also possible to add these types to your variables manually. In TypeScript:
97+
98+
```ts
99+
let page: import('playwright').Page;
100+
```
101+
102+
If you use JavaScript, you can still use TypeScript definitions for improved auto-completions and warnings in Visual Studio Code or WebStorm. Add the following to the top of your JavaScript file:
103+
104+
```js
105+
//@ts-check
106+
// ...
107+
```
108+
109+
You can also use JSDoc to set types for variables.
110+
111+
```js
112+
/** @type {import('playwright').Page} */
113+
let page;
114+
```
115+
116+
<br>
117+
88118
## Debugging scripts
89119

120+
### Using editor debugger
121+
90122
Playwright scripts can be developed just like any other Node.js script. For example, you can use the [Node.js debugger](https://nodejs.org/api/debugger.html) or [VS Code debugging](https://code.visualstudio.com/docs/nodejs/nodejs-debugging) to set breakpoints and get fine grained control over execution.
91123

92124
<a href="https://user-images.githubusercontent.com/284612/77234134-5f21a500-6b69-11ea-92ec-1c146e1333ec.png"><img src="https://user-images.githubusercontent.com/284612/77234134-5f21a500-6b69-11ea-92ec-1c146e1333ec.png" width="300" alt="Chromium Developer Tools"></a>
93125

94126
It is also possible to open **browser developer tools** during execution, to inspect the DOM tree or network activity.
95127

96-
<br>
128+
### Verbose logging
129+
130+
Playwright supports verbose logging with the `DEBUG` environment variable.
131+
132+
```sh
133+
# Linux/macOS
134+
$ DEBUG=pw:api npm run test
135+
136+
# Windows
137+
$ set DEBUG=pw:api
138+
$ npm run test
139+
```

docs/test-runners.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ With a few lines of code, you can hook up Playwright to your favorite JavaScript
66
- [Jest / Jasmine](#jest--jasmine)
77
- [AVA](#ava)
88
- [Mocha](#mocha)
9-
- [IDE support](#ide-support)
109
- [Multiple Browsers](#multiple-browsers)
1110
<!-- GEN:stop -->
1211

@@ -98,19 +97,6 @@ it('should work', async () => {
9897
```
9998
<br>
10099

101-
## IDE support
102-
103-
If using TypeScript, add types to your variables like:
104-
```ts
105-
let page: import('playwright').Page;
106-
```
107-
108-
If using JavaScript, you can still get nice autocompletions in VSCode or WebStorm by using JSDoc.
109-
```js
110-
/** @type {import('playwright').Page} */
111-
let page;
112-
```
113-
114100
## Multiple Browsers
115101

116102
These simple examples can be extended to support multiple browsers using an environment variable.

0 commit comments

Comments
 (0)