chore: move from esm to cjs before upstreaming (#986)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('test snapshot tool list', async ({ client }) => {
|
||||
const { tools } = await client.listTools();
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import url from 'node:url';
|
||||
import path from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('cdp server', async ({ cdpServer, startClient, server }) => {
|
||||
await cdpServer.start();
|
||||
@@ -84,9 +83,6 @@ test('should throw connection error and allow re-connecting', async ({ cdpServer
|
||||
});
|
||||
});
|
||||
|
||||
// NOTE: Can be removed when we drop Node.js 18 support and changed to import.meta.filename.
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
|
||||
test('does not support --device', async () => {
|
||||
const result = spawnSync('node', [
|
||||
path.join(__filename, '../../cli.js'), '--device=Pixel 5', '--cdp-endpoint=http://localhost:1234',
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_click', async ({ client, server, mcpBrowser }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { Config } from '../config.js';
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('config user data dir', async ({ startClient, server, mcpMode }, testInfo) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_console_messages', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_navigate', async ({ client, server }) => {
|
||||
expect(await client.callTool({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('--device should work', async ({ startClient, server, mcpMode }) => {
|
||||
const { client } = await startClient({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('alert dialog', async ({ client, server }) => {
|
||||
server.setContent('/', `<button onclick="alert('Alert')">Button</button>`, 'text/html');
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_evaluate', async ({ client, server }) => {
|
||||
expect(await client.callTool({
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_file_upload', async ({ client, server }, testInfo) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
import path from 'path';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
@@ -23,7 +22,7 @@ import { test as baseTest, expect as baseExpect } from '@playwright/test';
|
||||
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
import { ListRootsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { TestServer } from './testserver/index.ts';
|
||||
import { TestServer } from './testserver/index';
|
||||
|
||||
import type { Config } from '../config';
|
||||
import type { BrowserContext } from 'playwright';
|
||||
@@ -186,8 +185,6 @@ async function createTransport(args: string[], mcpMode: TestOptions['mcpMode'],
|
||||
transport: Transport,
|
||||
stderr: Stream | null,
|
||||
}> {
|
||||
// NOTE: Can be removed when we drop Node.js 18 support and changed to import.meta.filename.
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
if (mcpMode === 'docker') {
|
||||
const dockerArgs = ['run', '--rm', '-i', '--network=host', '-v', `${test.info().project.outputDir}:/app/test-results`];
|
||||
const transport = new StdioClientTransport({
|
||||
@@ -202,7 +199,7 @@ async function createTransport(args: string[], mcpMode: TestOptions['mcpMode'],
|
||||
|
||||
const transport = new StdioClientTransport({
|
||||
command: 'node',
|
||||
args: [path.join(path.dirname(__filename), '../cli.js'), ...args],
|
||||
args: [path.join(__dirname, '../cli.js'), ...args],
|
||||
cwd: path.dirname(test.info().config.configFile!),
|
||||
stderr: 'pipe',
|
||||
env: {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_fill_form (textbox)', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
for (const mcpHeadless of [false, true]) {
|
||||
test.describe(`mcpHeadless: ${mcpHeadless}`, () => {
|
||||
|
||||
@@ -14,20 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import url from 'node:url';
|
||||
import fs from 'fs';
|
||||
|
||||
import { ChildProcess, spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { ChildProcess, spawn } from 'child_process';
|
||||
import path from 'path';
|
||||
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
|
||||
import { test as baseTest, expect } from './fixtures.js';
|
||||
import { test as baseTest, expect } from './fixtures';
|
||||
import type { Config } from '../config.d.ts';
|
||||
|
||||
// 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: (options?: { args?: string[], noPort?: boolean }) => Promise<{ url: URL, stderr: () => string }> }>({
|
||||
serverEndpoint: async ({ mcpHeadless }, use, testInfo) => {
|
||||
let cp: ChildProcess | undefined;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('stitched aria frames', async ({ client }) => {
|
||||
expect(await client.callTool({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_install', async ({ client, mcpBrowser }) => {
|
||||
test.skip(mcpBrowser !== 'chromium', 'Test only chromium');
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import { test, expect, formatOutput } from './fixtures.js';
|
||||
import { test, expect, formatOutput } from './fixtures';
|
||||
|
||||
test('test reopen browser', async ({ startClient, server, mcpMode }) => {
|
||||
const { client, stderr } = await startClient();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import child_process from 'child_process';
|
||||
import fs from 'fs/promises';
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('library can be used from CommonJS', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright-mcp/issues/456' } }, async ({}, testInfo) => {
|
||||
const file = testInfo.outputPath('main.cjs');
|
||||
|
||||
@@ -21,7 +21,7 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
|
||||
|
||||
import { runMainBackend, runOnPauseBackendLoop } from '../src/mcp/mdb.js';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
import type * as mcpServer from '../src/mcp/server.js';
|
||||
import type { ServerBackendOnPause } from '../src/mcp/mdb.js';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_network_requests', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('save as pdf unavailable', async ({ startClient, server }) => {
|
||||
const { client } = await startClient();
|
||||
|
||||
@@ -18,7 +18,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { pathToFileURL } from 'url';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
import { createHash } from '../src/utils/guid.js';
|
||||
|
||||
const p = process.platform === 'win32' ? 'c:\\non\\existent\\folder' : '/non/existent/folder';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_take_screenshot (viewport)', async ({ startClient, server }, testInfo) => {
|
||||
const { client } = await startClient({
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('session log should record tool calls', async ({ startClient, server }, testInfo) => {
|
||||
const { client, stderr } = await startClient({
|
||||
|
||||
@@ -14,20 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import url from 'node:url';
|
||||
import fs from 'fs';
|
||||
|
||||
import { ChildProcess, spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { ChildProcess, spawn } from 'child_process';
|
||||
import path from 'path';
|
||||
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
|
||||
import { test as baseTest, expect } from './fixtures.js';
|
||||
import { test as baseTest, expect } from './fixtures';
|
||||
import type { Config } from '../config.d.ts';
|
||||
|
||||
// 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: (options?: { args?: string[], noPort?: boolean }) => Promise<{ url: URL, stderr: () => string }> }>({
|
||||
serverEndpoint: async ({ mcpHeadless }, use, testInfo) => {
|
||||
let cp: ChildProcess | undefined;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import url from 'node:url';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import path from 'path';
|
||||
@@ -25,9 +24,6 @@ import debug from 'debug';
|
||||
const fulfillSymbol = Symbol('fulfil callback');
|
||||
const rejectSymbol = Symbol('reject callback');
|
||||
|
||||
// NOTE: Can be removed when we drop Node.js 18 support and changed to import.meta.filename.
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
|
||||
export class TestServer {
|
||||
private _server: http.Server;
|
||||
readonly debugServer: any;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('check that trace is saved', async ({ startClient, server, mcpMode }, testInfo) => {
|
||||
const outputDir = testInfo.outputPath('output');
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_type', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test.use({ mcpArgs: ['--caps=verify'] });
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_connect(vscode) works', async ({ startClient, playwright, browserName }) => {
|
||||
const { client } = await startClient({
|
||||
@@ -27,7 +27,7 @@ test('browser_connect(vscode) works', async ({ startClient, playwright, browserN
|
||||
name: 'browser_connect',
|
||||
arguments: {
|
||||
connectionString: server.wsEndpoint(),
|
||||
lib: import.meta.resolve('playwright'),
|
||||
lib: require.resolve('playwright'),
|
||||
}
|
||||
})).toHaveResponse({
|
||||
result: 'Successfully connected.'
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_wait_for(text)', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect } from './fixtures.js';
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('do not falsely advertise user agent as a test driver', async ({ client, server, mcpBrowser }) => {
|
||||
test.skip(mcpBrowser === 'firefox');
|
||||
|
||||
Reference in New Issue
Block a user