chore: remove unnecessary args in ttest (#21012)

This commit is contained in:
Dmitry Gozman 2023-02-18 13:08:17 -08:00 committed by GitHub
parent 56dbd1fcb0
commit 595502ac46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 33 deletions

View File

@ -168,7 +168,6 @@ test('should focus a single nested test spec', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
expect(result.skipped).toBe(0);
console.log(JSON.stringify(result.report, null, 2));
expect(result.report.suites[0].specs[0].title).toEqual('pass3');
expect(result.report.suites[1].suites[0].suites[0].specs[0].title).toEqual('pass2');
});

View File

@ -86,11 +86,8 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
paramList.push(params[key] === true ? `${k}` : `${k}=${value}`);
}
}
const outputDir = path.join(baseDir, 'test-results');
const reportFile = path.join(outputDir, 'report.json');
const reportFile = path.join(baseDir, 'report.json');
const args = ['test'];
if (!options.usesCustomReporters)
args.push('--reporter=dot,json');
args.push(
'--workers=2',
...paramList
@ -101,6 +98,7 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
const cwd = options.cwd ? path.resolve(baseDir, options.cwd) : baseDir;
// eslint-disable-next-line prefer-const
let { exitCode, output } = await runPlaywrightCommand(childProcess, cwd, args, {
PW_TEST_REPORTER: path.join(__dirname, '../../packages/playwright-test/lib/reporters/json.js'),
PLAYWRIGHT_JSON_OUTPUT_NAME: reportFile,
...env,
}, options.sendSIGINTAfter);
@ -158,11 +156,7 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
}
function watchPlaywrightTest(childProcess: CommonFixtures['childProcess'], baseDir: string, env: NodeJS.ProcessEnv, options: RunOptions): TestChildProcess {
const paramList: string[] = [];
const outputDir = path.join(baseDir, 'test-results');
const args = ['test'];
args.push('--output=' + outputDir);
args.push('--workers=2', ...paramList);
const args = ['test', '--workers=2'];
if (options.additionalArgs)
args.push(...options.additionalArgs);
const cwd = options.cwd ? path.resolve(baseDir, options.cwd) : baseDir;
@ -224,7 +218,6 @@ function cleanEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
type RunOptions = {
sendSIGINTAfter?: number;
usesCustomReporters?: boolean;
additionalArgs?: string[];
cwd?: string,
};

View File

@ -158,7 +158,6 @@ test('should work with screenshot: on', async ({ runInlineTest }, testInfo) => {
'artifacts-two-contexts-failing',
' test-failed-1.png',
' test-failed-2.png',
'report.json',
]);
});
@ -185,7 +184,6 @@ test('should work with screenshot: only-on-failure', async ({ runInlineTest }, t
'artifacts-two-contexts-failing',
' test-failed-1.png',
' test-failed-2.png',
'report.json',
]);
});
@ -210,7 +208,6 @@ test('should work with screenshot: only-on-failure & fullPage', async ({ runInli
expect(listFiles(testInfo.outputPath('test-results'))).toEqual([
'artifacts-should-fail-and-take-fullPage-screenshots',
' test-failed-1.png',
'report.json',
]);
const screenshotFailure = fs.readFileSync(
testInfo.outputPath('test-results', 'artifacts-should-fail-and-take-fullPage-screenshots', 'test-failed-1.png')
@ -252,7 +249,6 @@ test('should work with trace: on', async ({ runInlineTest }, testInfo) => {
'artifacts-two-contexts-failing',
' trace-1.zip',
' trace.zip',
'report.json',
]);
});
@ -279,7 +275,6 @@ test('should work with trace: retain-on-failure', async ({ runInlineTest }, test
'artifacts-two-contexts-failing',
' trace-1.zip',
' trace.zip',
'report.json',
]);
});
@ -306,7 +301,6 @@ test('should work with trace: on-first-retry', async ({ runInlineTest }, testInf
'artifacts-two-contexts-failing-retry1',
' trace-1.zip',
' trace.zip',
'report.json',
]);
});

View File

@ -64,7 +64,7 @@ test('should stop tracing on requestContex.dispose()', async ({ runInlineTest, s
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
reporter: 'html',
reporter: [['html', { open: 'never' }]],
use: {
browserName: 'firefox',
trace:'retain-on-failure'

View File

@ -25,7 +25,7 @@ test('render expected', async ({ runInlineTest }) => {
expect(1).toBe(1);
});
`,
});
}, { reporter: 'dot' });
expect(result.rawOutput).toContain(colors.green('·'));
expect(result.exitCode).toBe(0);
});
@ -38,7 +38,7 @@ test('render unexpected', async ({ runInlineTest }) => {
expect(1).toBe(0);
});
`,
});
}, { reporter: 'dot' });
expect(result.rawOutput).toContain(colors.red('F'));
expect(result.exitCode).toBe(1);
});
@ -51,7 +51,7 @@ test('render unexpected after retry', async ({ runInlineTest }) => {
expect(1).toBe(0);
});
`,
}, { retries: 3 });
}, { retries: 3, reporter: 'dot' });
const text = result.output;
expect(text).toContain('×××F');
expect(result.rawOutput).toContain(colors.red('F'));
@ -66,7 +66,7 @@ test('render flaky', async ({ runInlineTest }) => {
expect(testInfo.retry).toBe(3);
});
`,
}, { retries: 3 });
}, { retries: 3, reporter: 'dot' });
const text = result.output;
expect(text).toContain('×××±');
expect(result.rawOutput).toContain(colors.yellow('±'));
@ -86,7 +86,7 @@ test('should work from config', async ({ runInlineTest }) => {
expect(1).toBe(1);
});
`,
});
}, { reporter: 'dot' });
expect(result.rawOutput).toContain(colors.green('·'));
expect(result.exitCode).toBe(0);
});
@ -99,7 +99,7 @@ test('render 243 tests in rows by 80', async ({ runInlineTest }) => {
test('test' + i, () => {});
}
`,
});
}, { reporter: 'dot' });
expect(result.exitCode).toBe(0);
expect(result.rawOutput).toContain(
colors.green('·').repeat(80) + '\n' +

View File

@ -914,7 +914,7 @@ test('should report clashing folders', async ({ runInlineTest }) => {
test('passes', async ({}) => {
});
`,
}, {}, {}, { usesCustomReporters: true });
});
expect(result.exitCode).toBe(0);
const output = result.output;
expect(output).toContain('Configuration Error');

View File

@ -123,7 +123,7 @@ test('should retry timeout', async ({ runInlineTest }) => {
await new Promise(f => setTimeout(f, 10000));
});
`
}, { timeout: 1000, retries: 2 });
}, { timeout: 1000, retries: 2, reporter: 'dot' });
expect(exitCode).toBe(1);
expect(passed).toBe(0);
expect(failed).toBe(1);
@ -154,7 +154,7 @@ test('should retry unexpected pass', async ({ runInlineTest }) => {
expect(1 + 1).toBe(2);
});
`
}, { retries: 2 });
}, { retries: 2, reporter: 'dot' });
expect(exitCode).toBe(1);
expect(passed).toBe(0);
expect(failed).toBe(1);
@ -174,7 +174,7 @@ test('should not retry expected failure', async ({ runInlineTest }) => {
expect(1 + 1).toBe(2);
});
`
}, { retries: 2 });
}, { retries: 2, reporter: 'dot' });
expect(exitCode).toBe(0);
expect(passed).toBe(2);
expect(failed).toBe(0);
@ -192,7 +192,7 @@ test('should retry unhandled rejection', async ({ runInlineTest }) => {
await new Promise(f => setTimeout(f, 2000));
});
`
}, { retries: 2 });
}, { retries: 2, reporter: 'dot' });
expect(result.exitCode).toBe(1);
expect(result.passed).toBe(0);
expect(result.failed).toBe(1);
@ -212,7 +212,7 @@ test('should retry beforeAll failure', async ({ runInlineTest }) => {
test('another passing test', async () => {
});
`
}, { retries: 2 });
}, { retries: 2, reporter: 'dot' });
expect(result.exitCode).toBe(1);
expect(result.passed).toBe(0);
expect(result.failed).toBe(1);
@ -236,7 +236,7 @@ test('should retry worker fixture setup failure', async ({ runInlineTest }) => {
test('passing test', async ({ worker }) => {
});
`
}, { retries: 2 });
}, { retries: 2, reporter: 'dot' });
expect(result.exitCode).toBe(1);
expect(result.passed).toBe(0);
expect(result.failed).toBe(1);

View File

@ -87,7 +87,7 @@ test('should default to package.json directory', async ({ runInlineTest }, testI
const result = await runInlineTest({
'foo/package.json': `{ "name": "foo" }`,
'foo/bar/playwright.config.js': `
module.exports = { projects: [ {} ] };
module.exports = { reporters: [], projects: [ {} ] };
`,
'foo/bar/baz/tests/a.spec.js': `
import { test, expect } from '@playwright/test';
@ -97,7 +97,7 @@ test('should default to package.json directory', async ({ runInlineTest }, testI
fs.writeFileSync(testInfo.outputPath('foo.ts'), 'foobar');
});
`
}, { 'reporter': '' }, {}, {
}, {}, { PW_TEST_REPORTER: '' }, {
cwd: 'foo/bar/baz/tests',
});
expect(result.exitCode).toBe(0);