Skip to content

Commit 3a938aa

Browse files
authored
feat(dev): Add VSCode playwright debug profile (#5262)
This adds a VSCode debugging profile for playwright tests, which works the same way the unit test debugging profile works - whatever file is open in the active editor will be the one tested, and the tests run in watch mode. Because playwright doesn't have a watch mode of its own[1], the profile uses the `nodemon` Node wrapper[2] to do the watching of files and restarting of tests whenever anything changes. [1] microsoft/playwright#7035 [2] https://github.com/remy/nodemon
1 parent 7573f19 commit 3a938aa

File tree

3 files changed

+320
-10
lines changed

3 files changed

+320
-10
lines changed

.vscode/launch.json

+28
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,34 @@
7777
"internalConsoleOptions": "neverOpen"
7878
},
7979

80+
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
81+
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
82+
// install the recommended extension Tasks Shell Input.
83+
{
84+
"name": "Debug playwright tests (just open file)",
85+
"type": "pwa-node",
86+
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
87+
"request": "launch",
88+
"runtimeExecutable": "yarn",
89+
"runtimeArgs": [
90+
// `nodemon` is basically `node --watch`
91+
"nodemon",
92+
// be default it only watches JS files, so have it watch TS files instead
93+
"--ext",
94+
"ts",
95+
"${workspaceFolder}/node_modules/playwright/node_modules/.bin/playwright",
96+
"test",
97+
"${file}"
98+
],
99+
"skipFiles": ["<node_internals>/**"],
100+
"outFiles": ["${workspaceFolder}/**/*.js", "!**/node_modules/**"],
101+
"sourceMaps": true,
102+
"smartStep": true,
103+
"internalConsoleOptions": "openOnSessionStart",
104+
// show stdout and stderr output in the debug console
105+
"outputCapture": "std"
106+
},
107+
80108
// @sentry/nextjs - Run a specific integration test file
81109
// Must have test file in currently active tab when hitting the play button, and must already have run `yarn` in test app directory
82110
{

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"lerna": "3.13.4",
8282
"madge": "4.0.2",
8383
"mocha": "^6.1.4",
84+
"nodemon": "^2.0.16",
8485
"npm-run-all": "^4.1.5",
8586
"prettier": "2.5.1",
8687
"recast": "^0.20.5",

0 commit comments

Comments
 (0)