Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: clarify that slow tests are about files (#10134)
Dmitry Gozman0a104bc50062
diff --git a/docs/src/test-advanced-js.md b/docs/src/test-advanced-js.mdindex ca61db62bc..6deedfeae5 100644--- a/docs/src/test-advanced-js.md+++ b/docs/src/test-advanced-js.md@@ -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.diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.mdindex a12ebdd306..e9fe2f195b 100644--- a/docs/src/test-api/class-testconfig.md+++ b/docs/src/test-api/class-testconfig.md@@ -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]>diff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.tsindex 76a8fd786d..189667a325 100644--- a/packages/playwright-test/src/reporters/base.ts+++ b/packages/playwright-test/src/reporters/base.ts@@ -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) {diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.tsindex c2d9d80497..d5e722237f 100644--- a/packages/playwright-test/types/test.d.ts+++ b/packages/playwright-test/types/test.d.ts@@ -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;diff --git a/tests/playwright-test/reporter-base.spec.ts b/tests/playwright-test/reporter-base.spec.tsindex b9698dbc9d..08223a59b8 100644--- a/tests/playwright-test/reporter-base.spec.ts+++ b/tests/playwright-test/reporter-base.spec.ts@@ -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 }) => {