chore: use rootPath instead of cwd when resolving seedFile (#37603)

This commit is contained in:
Dmitry Gozman 2025-09-26 20:06:25 +01:00 committed by GitHub
parent c46d8ee4e9
commit 6e88894622
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -147,7 +147,7 @@ test.describe('Test group', () => {
const candidateFiles: string[] = [];
candidateFiles.push(path.resolve(testDir, params.seedFile));
candidateFiles.push(path.resolve(configDir, params.seedFile));
candidateFiles.push(path.resolve(process.cwd(), params.seedFile));
candidateFiles.push(path.resolve(context.rootPath, params.seedFile));
for (const candidateFile of candidateFiles) {
if (await fileExistsAsync(candidateFile)) {
seedFile = candidateFile;

View File

@ -18,6 +18,7 @@ import { test, expect, writeFiles } from './fixtures';
import fs from 'fs';
import path from 'path';
import url from 'url';
test.use({ mcpServerType: 'test-mcp' });
@ -99,14 +100,14 @@ test('test_setup_page seed resolution', async ({ startClient }) => {
})).toHaveTextResponse(expect.stringContaining(`### Paused at end of test.`));
});
test('test_setup_page seed resolution - cwd', async ({ startClient }) => {
test('test_setup_page seed resolution - rootPath', async ({ startClient }) => {
await writeFiles({
'configs/playwright.config.ts': `
'packages/my-app/configs/playwright.config.ts': `
module.exports = {
testDir: '../tests',
};
`,
'tests/seed.test.ts': `
'packages/my-app/tests/seed.test.ts': `
import { test, expect } from '@playwright/test';
test('template', async ({ page }) => {
await page.setContent('<button>Submit</button>');
@ -115,13 +116,14 @@ test('test_setup_page seed resolution - cwd', async ({ startClient }) => {
});
const { client } = await startClient({
args: ['--config=configs/playwright.config.ts'],
args: ['--config=packages/my-app/configs/playwright.config.ts'],
roots: [{ name: 'root', uri: url.pathToFileURL(test.info().outputPath('')).toString() }],
});
expect(await client.callTool({
name: 'test_setup_page',
arguments: {
seedFile: 'tests/seed.test.ts',
seedFile: 'packages/my-app/tests/seed.test.ts',
},
})).toHaveTextResponse(expect.stringContaining(`### Paused at end of test.`));
});