chore: align test-server PATH with npx playwright test#671
Conversation
npx to align behaviour with CLIPATH with npx playwright test
|
turning into draft until I figured out the CI. |
|
This seems to be the wrong approach. It's really hard to make this work under windows, because |
|
This would be a substantial slowdown, especially on Windows. Is there a bug filed for this? |
|
There's no bug filed for this, it's something I noticed while going through open source repos. I pushed a different approach that works by manually extending |
| if (error.location) { | ||
| const document = await this._vscode.workspace.openTextDocument(error.location.file); | ||
| const position = new this._vscode.Position(error.location.line - 1, error.location.column - 1); | ||
| const position = new this._vscode.Position(Math.max(0, error.location.line - 1), error.location.column - 1); |
There was a problem hiding this comment.
These changes seem unrelated.
There was a problem hiding this comment.
They're unrelated, but I stumbled into weird errors here while working on this change. The Position constructor threw because of -1 being passed. Let me try reproing them.
There was a problem hiding this comment.
There was a problem hiding this comment.
There's several places where Playwright emits line: 0, column: 0: https://github.com/search?q=repo%3Amicrosoft%2Fplaywright%20line%3A%200&type=code
I'll kepp this in.
| let currentPath = path.resolve(cwd); | ||
| let previousPath; | ||
| while (previousPath !== currentPath) { | ||
| newPath.push(path.join(currentPath, 'node_modules', '.bin')); |
There was a problem hiding this comment.
Shouldn't we check that node_modules/.bin exists? Looks kinda wasteful to add all of them.
There was a problem hiding this comment.
I'm not sure! My hunch is that the system that resolves PATH is very optimised and much faster at checking path existence than our code. And because FS operations come at a premium under Windows, leaving the actual checks to the OS would be faster. This is all speculation though - do you happen to know more about this?
There was a problem hiding this comment.
No, I don't. I see that's what the other project does. Let's keep it as is.
We recommend running Playwright via
npx, which brings all project dependencies intoPATH. This means that in a webserver config,serve buildwill run the binary fromnode_modules/.bin/serve. Some projects in the wild make use of this (https://github.com/DerYeger/yeger, https://github.com/louislam/uptime-kuma), and so our extension fails spinning up a webserver that works just fine withnpx playwright test.To fix this, this PR adds env that resembles npx, loosely based on https://github.com/sindresorhus/npm-run-path/blob/main/index.js.