fix(ui-mode): respec --tsconfig option
Fixes https://github.com/microsoft/playwright/issues/32797
This commit is contained in:
parent
fbeba6619a
commit
3917f5e842
|
|
@ -48,6 +48,7 @@ export type TraceViewerRedirectOptions = {
|
||||||
isServer?: boolean;
|
isServer?: boolean;
|
||||||
outputDir?: string;
|
outputDir?: string;
|
||||||
updateSnapshots?: 'all' | 'none' | 'missing';
|
updateSnapshots?: 'all' | 'none' | 'missing';
|
||||||
|
tsconfig?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TraceViewerAppOptions = {
|
export type TraceViewerAppOptions = {
|
||||||
|
|
@ -137,6 +138,8 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
|
||||||
params.append('outputDir', options.outputDir);
|
params.append('outputDir', options.outputDir);
|
||||||
if (options.updateSnapshots)
|
if (options.updateSnapshots)
|
||||||
params.append('updateSnapshots', options.updateSnapshots);
|
params.append('updateSnapshots', options.updateSnapshots);
|
||||||
|
if (options.tsconfig)
|
||||||
|
params.append('tsconfig', options.tsconfig);
|
||||||
for (const reporter of options.reporter || [])
|
for (const reporter of options.reporter || [])
|
||||||
params.append('reporter', reporter);
|
params.append('reporter', reporter);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export interface TestServerInterface {
|
||||||
|
|
||||||
installBrowsers(params: {}): Promise<void>;
|
installBrowsers(params: {}): Promise<void>;
|
||||||
|
|
||||||
runGlobalSetup(params: { outputDir?: string }): Promise<{
|
runGlobalSetup(params: { outputDir?: string, tsconfig?: string }): Promise<{
|
||||||
report: ReportEntry[],
|
report: ReportEntry[],
|
||||||
status: reporterTypes.FullResult['status']
|
status: reporterTypes.FullResult['status']
|
||||||
}>;
|
}>;
|
||||||
|
|
@ -83,6 +83,7 @@ export interface TestServerInterface {
|
||||||
grep?: string;
|
grep?: string;
|
||||||
grepInvert?: string;
|
grepInvert?: string;
|
||||||
outputDir?: string;
|
outputDir?: string;
|
||||||
|
tsconfig?: string;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
report: ReportEntry[],
|
report: ReportEntry[],
|
||||||
status: reporterTypes.FullResult['status']
|
status: reporterTypes.FullResult['status']
|
||||||
|
|
@ -98,6 +99,7 @@ export interface TestServerInterface {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
outputDir?: string;
|
outputDir?: string;
|
||||||
updateSnapshots?: 'all' | 'none' | 'missing';
|
updateSnapshots?: 'all' | 'none' | 'missing';
|
||||||
|
tsconfig?: string;
|
||||||
reporters?: string[],
|
reporters?: string[],
|
||||||
trace?: 'on' | 'off';
|
trace?: 'on' | 'off';
|
||||||
video?: 'on' | 'off';
|
video?: 'on' | 'off';
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
||||||
timeout: cliOverrides.timeout,
|
timeout: cliOverrides.timeout,
|
||||||
outputDir: cliOverrides.outputDir,
|
outputDir: cliOverrides.outputDir,
|
||||||
updateSnapshots: cliOverrides.updateSnapshots,
|
updateSnapshots: cliOverrides.updateSnapshots,
|
||||||
|
tsconfig: cliOverrides.tsconfig,
|
||||||
});
|
});
|
||||||
await stopProfiling('runner');
|
await stopProfiling('runner');
|
||||||
if (status === 'restarted')
|
if (status === 'restarted')
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ export class TestServerDispatcher implements TestServerInterface {
|
||||||
|
|
||||||
const overrides: ConfigCLIOverrides = {
|
const overrides: ConfigCLIOverrides = {
|
||||||
outputDir: params.outputDir,
|
outputDir: params.outputDir,
|
||||||
|
tsconfig: params.tsconfig,
|
||||||
};
|
};
|
||||||
const { reporter, report } = await this._collectingInternalReporter(new ListReporter());
|
const { reporter, report } = await this._collectingInternalReporter(new ListReporter());
|
||||||
const config = await this._loadConfigOrReportError(reporter, overrides);
|
const config = await this._loadConfigOrReportError(reporter, overrides);
|
||||||
|
|
@ -242,6 +243,7 @@ export class TestServerDispatcher implements TestServerInterface {
|
||||||
repeatEach: 1,
|
repeatEach: 1,
|
||||||
retries: 0,
|
retries: 0,
|
||||||
outputDir: params.outputDir,
|
outputDir: params.outputDir,
|
||||||
|
tsconfig: params.tsconfig,
|
||||||
};
|
};
|
||||||
const { reporter, report } = await this._collectingInternalReporter();
|
const { reporter, report } = await this._collectingInternalReporter();
|
||||||
const config = await this._loadConfigOrReportError(reporter, overrides);
|
const config = await this._loadConfigOrReportError(reporter, overrides);
|
||||||
|
|
@ -308,6 +310,7 @@ export class TestServerDispatcher implements TestServerInterface {
|
||||||
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined,
|
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined,
|
||||||
},
|
},
|
||||||
outputDir: params.outputDir,
|
outputDir: params.outputDir,
|
||||||
|
tsconfig: params.tsconfig,
|
||||||
updateSnapshots: params.updateSnapshots,
|
updateSnapshots: params.updateSnapshots,
|
||||||
workers: params.workers,
|
workers: params.workers,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ const queryParams = {
|
||||||
updateSnapshots: (searchParams.get('updateSnapshots') as 'all' | 'none' | 'missing' | undefined) || undefined,
|
updateSnapshots: (searchParams.get('updateSnapshots') as 'all' | 'none' | 'missing' | undefined) || undefined,
|
||||||
reporters: searchParams.has('reporter') ? searchParams.getAll('reporter') : undefined,
|
reporters: searchParams.has('reporter') ? searchParams.getAll('reporter') : undefined,
|
||||||
pathSeparator: searchParams.get('pathSeparator') || '/',
|
pathSeparator: searchParams.get('pathSeparator') || '/',
|
||||||
|
tsconfig: searchParams.get('tsconfig') || undefined,
|
||||||
};
|
};
|
||||||
if (queryParams.updateSnapshots && !['all', 'none', 'missing'].includes(queryParams.updateSnapshots))
|
if (queryParams.updateSnapshots && !['all', 'none', 'missing'].includes(queryParams.updateSnapshots))
|
||||||
queryParams.updateSnapshots = undefined;
|
queryParams.updateSnapshots = undefined;
|
||||||
|
|
@ -189,12 +190,13 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
});
|
});
|
||||||
const { status, report } = await testServerConnection.runGlobalSetup({
|
const { status, report } = await testServerConnection.runGlobalSetup({
|
||||||
outputDir: queryParams.outputDir,
|
outputDir: queryParams.outputDir,
|
||||||
|
tsconfig: queryParams.tsconfig,
|
||||||
});
|
});
|
||||||
teleSuiteUpdater.processGlobalReport(report);
|
teleSuiteUpdater.processGlobalReport(report);
|
||||||
if (status !== 'passed')
|
if (status !== 'passed')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert, outputDir: queryParams.outputDir });
|
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert, outputDir: queryParams.outputDir, tsconfig: queryParams.tsconfig });
|
||||||
teleSuiteUpdater.processListReport(result.report);
|
teleSuiteUpdater.processListReport(result.report);
|
||||||
|
|
||||||
testServerConnection.onReport(params => {
|
testServerConnection.onReport(params => {
|
||||||
|
|
@ -300,6 +302,7 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
updateSnapshots: updateSnapshots ? 'all' : queryParams.updateSnapshots,
|
updateSnapshots: updateSnapshots ? 'all' : queryParams.updateSnapshots,
|
||||||
reporters: queryParams.reporters,
|
reporters: queryParams.reporters,
|
||||||
trace: 'on',
|
trace: 'on',
|
||||||
|
tsconfig: queryParams.tsconfig,
|
||||||
});
|
});
|
||||||
// Clear pending tests in case of interrupt.
|
// Clear pending tests in case of interrupt.
|
||||||
for (const test of testModel.rootSuite?.allTests() || []) {
|
for (const test of testModel.rootSuite?.allTests() || []) {
|
||||||
|
|
@ -319,7 +322,7 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
commandQueue.current = commandQueue.current.then(async () => {
|
commandQueue.current = commandQueue.current.then(async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert, outputDir: queryParams.outputDir });
|
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert, outputDir: queryParams.outputDir, tsconfig: queryParams.tsconfig });
|
||||||
teleSuiteUpdater.processListReport(result.report);
|
teleSuiteUpdater.processListReport(result.report);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
||||||
|
|
@ -444,3 +444,60 @@ test('should show proper total when using deps', async ({ runUITest }) => {
|
||||||
`);
|
`);
|
||||||
await expect(page.getByTestId('status-line')).toHaveText('2/2 passed (100%)');
|
await expect(page.getByTestId('status-line')).toHaveText('2/2 passed (100%)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should respect --tsconfig option', async ({ runUITest }) => {
|
||||||
|
const { page } = await runUITest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
import { foo } from '~/foo';
|
||||||
|
export default {
|
||||||
|
testDir: './tests' + foo,
|
||||||
|
};
|
||||||
|
`,
|
||||||
|
'tsconfig.json': `{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["./does-not-exist/*"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`,
|
||||||
|
'tsconfig.special.json': `{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["./mapped-from-root/*"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`,
|
||||||
|
'mapped-from-root/foo.ts': `
|
||||||
|
export const foo = 42;
|
||||||
|
`,
|
||||||
|
'tests42/tsconfig.json': `{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["../should-be-ignored/*"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}`,
|
||||||
|
'tests42/a.test.ts': `
|
||||||
|
import { foo } from '~/foo';
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('test', ({}) => {
|
||||||
|
expect(foo).toBe(42);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
'should-be-ignored/foo.ts': `
|
||||||
|
export const foo = 43;
|
||||||
|
`,
|
||||||
|
}, undefined, { additionalArgs: ['--tsconfig=tsconfig.special.json'] });
|
||||||
|
|
||||||
|
await page.getByTitle('Run all').click();
|
||||||
|
|
||||||
|
await expect.poll(dumpTestTree(page)).toBe(`
|
||||||
|
▼ ✅ a.test.ts
|
||||||
|
✅ test
|
||||||
|
`);
|
||||||
|
|
||||||
|
await expect(page.getByTestId('status-line')).toHaveText('1/1 passed (100%)');
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue