mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: clarify that slow tests are about files (#10134)
This commit is contained in:
parent
ac25a67140
commit
0a104bc500
@ -40,7 +40,7 @@ These options would be typically different between local development and CI oper
|
||||
- `projects: Project[]` - Multiple [projects](#projects) configuration.
|
||||
- `quiet: boolean` - Whether to suppress stdout and stderr from the tests.
|
||||
- `reporter: 'list' | 'line' | 'dot' | 'json' | 'junit' | 'github' | 'html' | 'null'` - The reporter to use. See [reporters](./test-reporters.md) for details.
|
||||
- `reportSlowTests: { max: number, threshold: number } | null` - Whether to report slow tests. When `null`, slow tests are not reported. Otherwise, tests that took more than `threshold` milliseconds are reported as slow, but no more than `max` number of them. Passing zero as `max` reports all slow tests that exceed the threshold.
|
||||
- `reportSlowTests: { max: number, threshold: number } | null` - Whether to report slow test files. When `null`, slow test files are not reported. Otherwise, test files that took more than `threshold` milliseconds are reported as slow, but no more than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
|
||||
- `shard: { total: number, current: number } | null` - [Shard](./test-parallel.md#shard-tests-between-multiple-machines) information.
|
||||
- `updateSnapshots: boolean` - Whether to update expected snapshots with the actual results produced by the test run.
|
||||
- `workers: number` - The maximum number of concurrent worker processes to use for parallelizing tests.
|
||||
|
||||
@ -358,12 +358,12 @@ export default config;
|
||||
|
||||
## property: TestConfig.reportSlowTests
|
||||
- type: <[Object]>
|
||||
- `max` <[int]> The maximum number of slow tests to report. Defaults to `5`.
|
||||
- `max` <[int]> The maximum number of slow test files to report. Defaults to `5`.
|
||||
- `threshold` <[float]> Test duration in milliseconds that is considered slow. Defaults to 15 seconds.
|
||||
|
||||
Whether to report slow tests. Pass `null` to disable this feature.
|
||||
Whether to report slow test files. Pass `null` to disable this feature.
|
||||
|
||||
Tests that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more than `max` number of them. Passing zero as `max` reports all slow tests that exceed the threshold.
|
||||
Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
|
||||
|
||||
## property: TestConfig.retries
|
||||
- type: <[int]>
|
||||
|
||||
@ -198,9 +198,12 @@ export class BaseReporter implements Reporter {
|
||||
}
|
||||
|
||||
private _printSlowTests() {
|
||||
this.getSlowTests().forEach(([file, duration]) => {
|
||||
console.log(colors.yellow(' Slow test: ') + file + colors.yellow(` (${milliseconds(duration)})`));
|
||||
const slowTests = this.getSlowTests();
|
||||
slowTests.forEach(([file, duration]) => {
|
||||
console.log(colors.yellow(' Slow test file: ') + file + colors.yellow(` (${milliseconds(duration)})`));
|
||||
});
|
||||
if (slowTests.length)
|
||||
console.log(colors.yellow(' Consider splitting slow test files to speed up parallel execution'));
|
||||
}
|
||||
|
||||
private _printSummary(summary: string) {
|
||||
|
||||
12
packages/playwright-test/types/test.d.ts
vendored
12
packages/playwright-test/types/test.d.ts
vendored
@ -546,10 +546,10 @@ interface TestConfig {
|
||||
*/
|
||||
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
|
||||
/**
|
||||
* Whether to report slow tests. Pass `null` to disable this feature.
|
||||
* Whether to report slow test files. Pass `null` to disable this feature.
|
||||
*
|
||||
* Tests that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more than
|
||||
* `max` number of them. Passing zero as `max` reports all slow tests that exceed the threshold.
|
||||
* Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more
|
||||
* than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
|
||||
*/
|
||||
reportSlowTests?: ReportSlowTests;
|
||||
/**
|
||||
@ -965,10 +965,10 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
|
||||
*/
|
||||
reporter: ReporterDescription[];
|
||||
/**
|
||||
* Whether to report slow tests. Pass `null` to disable this feature.
|
||||
* Whether to report slow test files. Pass `null` to disable this feature.
|
||||
*
|
||||
* Tests that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more than
|
||||
* `max` number of them. Passing zero as `max` reports all slow tests that exceed the threshold.
|
||||
* Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more
|
||||
* than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
|
||||
*/
|
||||
reportSlowTests: ReportSlowTests;
|
||||
rootDir: string;
|
||||
|
||||
@ -124,14 +124,15 @@ test('should print slow tests', async ({ runInlineTest }) => {
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(8);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test: [foo] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test: [bar] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test: [baz] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test: [qux] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test: [foo] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test: [bar] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test: [baz] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test: [qux] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test file: [foo] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test file: [bar] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test file: [baz] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Slow test file: [qux] › dir${path.sep}a.test.js (`);
|
||||
expect(stripAscii(result.output)).toContain(`Consider splitting slow test files to speed up parallel execution`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test file: [foo] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test file: [bar] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test file: [baz] › dir${path.sep}b.test.js (`);
|
||||
expect(stripAscii(result.output)).not.toContain(`Slow test file: [qux] › dir${path.sep}b.test.js (`);
|
||||
});
|
||||
|
||||
test('should not print slow tests', async ({ runInlineTest }) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user