chore: migrate to ESM (#303)
- [Why do I need `.js` extension?](https://stackoverflow.com/a/77150985/6512681) - [Why setting `rootDir` in the `tsconfig.json`?](https://stackoverflow.com/a/58941798/6512681) - [How to ensure that we add the `.js` extension via ESLint](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md#importextensions) Fixes https://github.com/microsoft/playwright-mcp/issues/302
This commit is contained in:
@@ -14,14 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import url from 'node:url';
|
||||
import { spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { test as baseTest } from './fixtures';
|
||||
import { test as baseTest } from './fixtures.js';
|
||||
import { expect } from 'playwright/test';
|
||||
|
||||
// NOTE: Can be removed when we drop Node.js 18 support and changed to import.meta.filename.
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
|
||||
const test = baseTest.extend<{ serverEndpoint: string }>({
|
||||
serverEndpoint: async ({}, use) => {
|
||||
const cp = spawn('node', [path.join(__dirname, '../cli.js'), '--port', '0'], { stdio: 'pipe' });
|
||||
const cp = spawn('node', [path.join(path.dirname(__filename), '../cli.js'), '--port', '0'], { stdio: 'pipe' });
|
||||
try {
|
||||
let stdout = '';
|
||||
const url = await new Promise<string>(resolve => cp.stdout?.on('data', data => {
|
||||
|
||||
Reference in New Issue
Block a user