playwright-performance-regression 0.1.0-next.1 → 0.1.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +431 -0
  2. package/README.md +96 -64
  3. package/dist/{chunk-L5C63HEF.js → chunk-CISGJCFW.js} +378 -48
  4. package/dist/chunk-CXE5IWZY.js +1648 -0
  5. package/dist/{chunk-B64P2D5A.js → chunk-E2IX265O.js} +395 -206
  6. package/dist/chunk-IUI4AFE5.cjs +658 -0
  7. package/dist/{chunk-WZVQK7CQ.cjs → chunk-KELMALEG.cjs} +408 -218
  8. package/dist/{chunk-GCA73FFP.cjs → chunk-LUA4WRIQ.cjs} +382 -47
  9. package/dist/chunk-RL27E3AB.js +595 -0
  10. package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
  11. package/dist/cli.js +2761 -2339
  12. package/dist/config.cjs +122 -137
  13. package/dist/config.d.cts +3 -2
  14. package/dist/config.d.ts +3 -2
  15. package/dist/config.js +117 -132
  16. package/dist/fixture.cjs +9 -5
  17. package/dist/fixture.d.cts +10 -4
  18. package/dist/fixture.d.ts +10 -4
  19. package/dist/fixture.js +4 -4
  20. package/dist/index.cjs +3 -3
  21. package/dist/index.d.cts +121 -25
  22. package/dist/index.d.ts +121 -25
  23. package/dist/index.js +1 -1
  24. package/dist/perf-api-2DH_keLh.d.cts +17 -0
  25. package/dist/perf-api-2DH_keLh.d.ts +17 -0
  26. package/dist/reporter.cjs +5713 -1237
  27. package/dist/reporter.js +6905 -693
  28. package/dist/test.cjs +4 -4
  29. package/dist/test.js +4 -4
  30. package/package.json +19 -1
  31. package/schemas/common.schema.json +2 -2
  32. package/schemas/config.schema.json +72 -26
  33. package/schemas/outcome.schema.json +2 -2
  34. package/schemas/run-report.schema.json +549 -20
  35. package/schemas/samples.schema.json +48 -37
  36. package/schemas/thresholds.schema.json +1 -1
  37. package/dist/chunk-3CLCMD2Q.js +0 -3411
  38. package/dist/chunk-4SFI55HF.cjs +0 -319
  39. package/dist/chunk-HBGADXLP.js +0 -254
  40. package/dist/perf-api-V4PeHVE0.d.cts +0 -22
  41. package/dist/perf-api-V4PeHVE0.d.ts +0 -22
package/dist/index.d.cts CHANGED
@@ -11,35 +11,43 @@ interface PackageConfig {
11
11
  */
12
12
  run?: {
13
13
  /**
14
- * Environment label (D-18). Overridden by PW_PERF_ENV / --env. Null: no label, one set of thresholds files.
14
+ * Environment label (D-18). Overridden by PW_PERF_ENV. Null: no label, one set of thresholds files.
15
15
  */
16
16
  env?: string | null;
17
17
  /**
18
- * Repetitions of each measured test (D-03). Overridden by PW_PERF_REPEAT / --repeat for the current mode.
18
+ * Passes of the test command (D-03, D-39): the command runs once per pass and every test runs once in each pass. Overridden by PW_PERF_PASSES for the current mode.
19
19
  */
20
- repeat?: {
20
+ passes?: {
21
21
  /**
22
- * Repetitions in a measurement run.
22
+ * Passes in a measurement run.
23
23
  */
24
24
  test?: number;
25
25
  /**
26
- * Repetitions in a thresholds derivation run.
26
+ * Passes in a thresholds derivation run.
27
27
  */
28
28
  thresholds?: number;
29
29
  };
30
30
  /**
31
- * Which Playwright projects are measured and repeated in perf mode (D-04, D-13, D-22; behaviour: 04-REQ-18). 'auto': projects whose effective browser is Chromium (use.browserName, else use.defaultBrowserType from a device descriptor, else chromium; chrome/msedge channels count as Chromium) and which are neither a dependency nor a teardown of another project. A list: exactly these project names; a listed project that is also a dependency of another listed project is measured and repeated too.
31
+ * Only tests whose title or tags match this regular expression run in perf mode, e.g. '@perf' (03-REQ-25). Applied case-insensitively to the projects that are measured (all but setup and teardown projects, 04-REQ-18); setup and teardown projects run in full. null: all tests.
32
32
  */
33
- projects?: 'auto' | [string, ...string[]];
33
+ grep?: null | string;
34
34
  /**
35
- * Reporters kept in perf mode by name, as in the Playwright reporter config (e.g. 'junit', 'allure-playwright'). By default withPerf() keeps only the console reporters (list, line, dot, github) and the package reporter (D-23, 04-REQ-32).
35
+ * Reporters kept in perf mode by name, as in the Playwright reporter config (e.g. 'junit', 'allure-playwright'). By default withPerf() keeps only the console reporters line, dot and github (list becomes dot; name list here to keep it) and the package reporter (D-23, 04-REQ-32).
36
36
  */
37
37
  keepReporters?: string[];
38
+ /**
39
+ * Sets use.launchOptions.slowMo to 0 in every measured project in perf mode (03-REQ-27, D-45). slowMo delays every browser action and distorts the measured times; off by default because some tests are unstable without it. false: slowMo stays and perf mode warns about it (CONFIG_SLOW_MO).
40
+ */
41
+ overrideSlowMo?: boolean;
38
42
  };
39
43
  /**
40
44
  * What the collector measures (05).
41
45
  */
42
46
  measure?: {
47
+ /**
48
+ * Requests the browser makes to the backend and calls of the request fixture, page.request and context.request (keys with the prefix 'request '), as keys of kind 'api' (05, 15, 03-REQ-28). false: no request is measured, the api thresholds file is neither read nor written, and only test.step durations are measured; measure.api and measure.steps cannot both be off.
49
+ */
50
+ api?: boolean;
43
51
  /**
44
52
  * Playwright resource types that are measured. WebSocket traffic is not available as Request events in Playwright and cannot be measured (05).
45
53
  *
@@ -81,6 +89,58 @@ interface PackageConfig {
81
89
  * @minItems 1
82
90
  */
83
91
  successStatuses?: [string, ...string[]];
92
+ /**
93
+ * Durations of test.step steps as keys of kind 'step' (06). true (default) enables with defaults, false disables, an object enables with settings (03-REQ-18).
94
+ */
95
+ steps?: boolean | {
96
+ /**
97
+ * Default true when an object is given.
98
+ */
99
+ enabled?: boolean;
100
+ /**
101
+ * When not empty, only steps whose step key part matches at least one pattern give samples (06-REQ-22).
102
+ *
103
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
104
+ */
105
+ include?: (string | {
106
+ regex: string;
107
+ flags?: string;
108
+ })[];
109
+ /**
110
+ * Steps whose step key part matches any pattern give no samples; exclude wins over include.
111
+ *
112
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
113
+ */
114
+ exclude?: (string | {
115
+ regex: string;
116
+ flags?: string;
117
+ })[];
118
+ /**
119
+ * Deepest step level measured; deeper steps are included in their ancestor's time (06-REQ-21).
120
+ */
121
+ maxDepth?: number;
122
+ /**
123
+ * Playwright step categories measured (06-REQ-20). Steps of other categories are transparent for keys and depth.
124
+ *
125
+ * @minItems 1
126
+ */
127
+ categories?: [
128
+ 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook',
129
+ ...('test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook')[]
130
+ ];
131
+ /**
132
+ * 'step': one key per step path across tests; 'test': one key per test and step path (06-REQ-23).
133
+ */
134
+ groupBy?: 'step' | 'test';
135
+ /**
136
+ * false skips the key-stability rules (ids, dates, numbers); privacy rules always apply (06-REQ-35).
137
+ */
138
+ normalizeTitles?: boolean;
139
+ /**
140
+ * true replaces quoted values in step titles with :value; by default they stay in keys (06-D-26).
141
+ */
142
+ redactQuotedValues?: boolean;
143
+ };
84
144
  /**
85
145
  * How long the collector waits at test end for requests still in flight (05).
86
146
  */
@@ -91,7 +151,7 @@ interface PackageConfig {
91
151
  */
92
152
  keys?: {
93
153
  /**
94
- * Origin to label mapping, e.g. {"https://api.example.com": "api"}. The origin of Playwright use.baseURL gets the empty label unless mapped here. Other origins are labeled with their host.
154
+ * Origin to label mapping, e.g. {"https://api.example.com": "api"}. A key with * is a host pattern, e.g. "https://*.ci.example.com" (one * per host label, never across a dot); an exact entry wins over a pattern. The origin of Playwright use.baseURL gets the empty label unless mapped here. Other origins are labeled with their host.
95
155
  */
96
156
  origins?: {
97
157
  [k: string]: string;
@@ -114,6 +174,10 @@ interface PackageConfig {
114
174
  * Random-looking ids of at least 16 characters with a digit, a lowercase and an uppercase letter, e.g. nanoid (07-REQ-08).
115
175
  */
116
176
  mixed?: boolean;
177
+ /**
178
+ * Ids with a prefix: 2-5 capital letters, '-' and at least 3 digits (ORD-1000), or 1-8 lowercase letters, '_' and at least 2 digits or 8-32 letters and digits with a digit (inv_58) (07-REQ-08).
179
+ */
180
+ prefixed?: boolean;
117
181
  /**
118
182
  * E-mail addresses, replaced with ':email' (07-REQ-08).
119
183
  */
@@ -193,7 +257,7 @@ interface PackageConfig {
193
257
  /**
194
258
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
195
259
  */
196
- custom?: number;
260
+ step?: number;
197
261
  };
198
262
  };
199
263
  /**
@@ -223,7 +287,7 @@ interface PackageConfig {
223
287
  /**
224
288
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
225
289
  */
226
- custom?: number;
290
+ step?: number;
227
291
  };
228
292
  /**
229
293
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -283,7 +347,7 @@ interface PackageConfig {
283
347
  /**
284
348
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
285
349
  */
286
- custom?: number;
350
+ step?: number;
287
351
  };
288
352
  };
289
353
  };
@@ -309,7 +373,7 @@ interface PackageConfig {
309
373
  */
310
374
  medianFactor?: number;
311
375
  };
312
- custom?: {
376
+ step?: {
313
377
  /**
314
378
  * Lower clamp of derived T.
315
379
  */
@@ -360,7 +424,7 @@ interface PackageConfig {
360
424
  /**
361
425
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
362
426
  */
363
- custom?: number;
427
+ step?: number;
364
428
  };
365
429
  };
366
430
  /**
@@ -411,7 +475,7 @@ interface PackageConfig {
411
475
  /**
412
476
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
413
477
  */
414
- custom?: number;
478
+ step?: number;
415
479
  };
416
480
  };
417
481
  };
@@ -428,7 +492,7 @@ interface PackageConfig {
428
492
  */
429
493
  minSamples?: number;
430
494
  /**
431
- * Request statuses counted as errors by the 'errors' rule (08, 09): a class like '5xx', an exact code like '429', FAILED (request failed without a response, not aborted), ABORTED (cancelled by the browser, e.g. on navigation), PENDING (still in flight at test end). Custom measurements: outcomes error and unfinished are always errors.
495
+ * Request statuses counted as errors by the 'errors' rule (08, 09): a class like '5xx', an exact code like '429', FAILED (request failed without a response, not aborted), ABORTED (cancelled by the browser, e.g. on navigation), PENDING (still in flight at test end).
432
496
  */
433
497
  statuses?: string[];
434
498
  /**
@@ -442,7 +506,7 @@ interface PackageConfig {
442
506
  /**
443
507
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
444
508
  */
445
- custom?: number;
509
+ step?: number;
446
510
  };
447
511
  /**
448
512
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -479,10 +543,6 @@ interface PackageConfig {
479
543
  * 'block': violations on keys evaluated with default thresholds can fail the run; 'warn': they only warn.
480
544
  */
481
545
  defaultThresholds?: 'block' | 'warn';
482
- /**
483
- * Report violations but never fail the run.
484
- */
485
- warnOnly?: boolean;
486
546
  /**
487
547
  * Highest share of failed test executions (unexpected / executed, skipped excluded) for which the run result is still trustworthy. Above it the run ends with tool error TESTS_FAILED_TOO_MANY (exit code 3, 09). Failed tests below it are a warning only: in perf mode the performance result decides (00, chapter 11).
488
548
  */
@@ -492,12 +552,16 @@ interface PackageConfig {
492
552
  * Thresholds files and derivation (10).
493
553
  */
494
554
  thresholds?: {
555
+ /**
556
+ * Headroom preset for derived thresholds (D-41, 10-REQ-23): sets the defaults of every checks.*.margin; margin fields set explicitly win. strict: small headroom, catches smaller regressions, more false alarms on a noisy environment. normal: recommended start. loose: large headroom, only clear regressions, for shared noisy environments.
557
+ */
558
+ preset?: 'strict' | 'normal' | 'loose';
495
559
  /**
496
560
  * Directory of thresholds files, relative to the Playwright config directory.
497
561
  */
498
562
  dir?: string;
499
563
  /**
500
- * File name prefix; files are <prefix>.<kind>[.<env>].json.
564
+ * File name prefix; files are <prefix>[.steps][.<env>].json.
501
565
  */
502
566
  filePrefix?: string;
503
567
  /**
@@ -531,7 +595,7 @@ interface PackageConfig {
531
595
  */
532
596
  report?: {
533
597
  /**
534
- * Directory of report.json and report.html, relative to the Playwright config directory.
598
+ * Directory of report.json and report.html, relative to the Playwright config directory. Emptied when the first test of a test or thresholds run starts; never the project directory or a folder with thresholds files.
535
599
  */
536
600
  dir?: string;
537
601
  /**
@@ -570,6 +634,24 @@ type Override<T, U> = {
570
634
  [K in keyof T]: K extends keyof U ? U[K] extends Whole ? U[K] : U[K] extends object ? Override<T[K], U[K]> : U[K] : T[K];
571
635
  };
572
636
 
637
+ type StepCategory = 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook';
638
+ type JsonPattern = string | {
639
+ regex: string;
640
+ flags?: string;
641
+ };
642
+ /** measure.steps after resolution, in JSON form (snapshot in the run report). */
643
+ interface StepsSettingsJson {
644
+ enabled: boolean;
645
+ include: JsonPattern[];
646
+ exclude: JsonPattern[];
647
+ maxDepth: number;
648
+ /** Non-empty (03-REQ-18). */
649
+ categories: [StepCategory, ...StepCategory[]];
650
+ groupBy: 'step' | 'test';
651
+ normalizeTitles: boolean;
652
+ redactQuotedValues: boolean;
653
+ }
654
+
573
655
  /** JSON form of the package config: a JSON config file or the snapshot in the run report. */
574
656
  type PerfConfigJson = PackageConfig;
575
657
  /** A string matches as a case-sensitive substring; RegExp and { regex, flags } are regexes. */
@@ -591,12 +673,17 @@ type PerfConfigInput = DeepPartial<Override<PerfConfigJson, {
591
673
  measure: {
592
674
  include: UrlPattern[];
593
675
  exclude: UrlPattern[];
676
+ steps: boolean | (Omit<StepsSettingsJson, 'include' | 'exclude'> & StepPatternsInput);
594
677
  };
595
678
  keys: {
596
679
  extraIdPatterns: UrlPattern[];
597
680
  keyBuilder: KeyBuilder;
598
681
  };
599
682
  }>>;
683
+ interface StepPatternsInput {
684
+ include: UrlPattern[];
685
+ exclude: UrlPattern[];
686
+ }
600
687
  /** Every property required, recursively; arrays and tuples are kept as they are. */
601
688
  type Complete<T> = T extends readonly unknown[] ? T : T extends object ? {
602
689
  [K in keyof T]-?: Complete<Exclude<T[K], undefined>>;
@@ -606,7 +693,10 @@ type CompleteJson = Complete<Omit<PerfConfigJson, '$schema'>>;
606
693
  * JSON form of a fully resolved config: every option has a value. keys.keyBuilder is present
607
694
  * ("[function]") only when a key builder function was configured (02-REQ-17).
608
695
  */
609
- type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
696
+ type ResolvedConfigJson = Omit<CompleteJson, 'keys' | 'measure'> & {
697
+ measure: Omit<CompleteJson['measure'], 'steps'> & {
698
+ steps: StepsSettingsJson;
699
+ };
610
700
  keys: Omit<CompleteJson['keys'], 'keyBuilder'> & {
611
701
  keyBuilder?: '[function]';
612
702
  };
@@ -615,15 +705,21 @@ type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
615
705
  type ResolvedUrlPattern = string | RegExp;
616
706
  /** Fully resolved config: all options filled in, patterns compiled (03, chapter 5). */
617
707
  type ResolvedConfig = Omit<ResolvedConfigJson, 'measure' | 'keys'> & {
618
- measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude'> & {
708
+ measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude' | 'steps'> & {
619
709
  include: ResolvedUrlPattern[];
620
710
  exclude: ResolvedUrlPattern[];
711
+ steps: ResolvedStepsSettings;
621
712
  };
622
713
  keys: Omit<ResolvedConfigJson['keys'], 'extraIdPatterns' | 'keyBuilder'> & {
623
714
  extraIdPatterns: ResolvedUrlPattern[];
624
715
  keyBuilder: KeyBuilder | undefined;
625
716
  };
626
717
  };
718
+ /** measure.steps after resolution: full object, patterns compiled (03-REQ-18). */
719
+ type ResolvedStepsSettings = Omit<StepsSettingsJson, 'include' | 'exclude'> & {
720
+ include: ResolvedUrlPattern[];
721
+ exclude: ResolvedUrlPattern[];
722
+ };
627
723
 
628
724
  /** Returns `config` unchanged; it only gives editor type hints in a config file (D-15). */
629
725
  declare function definePerfConfig(config: PerfConfigInput): PerfConfigInput;
package/dist/index.d.ts CHANGED
@@ -11,35 +11,43 @@ interface PackageConfig {
11
11
  */
12
12
  run?: {
13
13
  /**
14
- * Environment label (D-18). Overridden by PW_PERF_ENV / --env. Null: no label, one set of thresholds files.
14
+ * Environment label (D-18). Overridden by PW_PERF_ENV. Null: no label, one set of thresholds files.
15
15
  */
16
16
  env?: string | null;
17
17
  /**
18
- * Repetitions of each measured test (D-03). Overridden by PW_PERF_REPEAT / --repeat for the current mode.
18
+ * Passes of the test command (D-03, D-39): the command runs once per pass and every test runs once in each pass. Overridden by PW_PERF_PASSES for the current mode.
19
19
  */
20
- repeat?: {
20
+ passes?: {
21
21
  /**
22
- * Repetitions in a measurement run.
22
+ * Passes in a measurement run.
23
23
  */
24
24
  test?: number;
25
25
  /**
26
- * Repetitions in a thresholds derivation run.
26
+ * Passes in a thresholds derivation run.
27
27
  */
28
28
  thresholds?: number;
29
29
  };
30
30
  /**
31
- * Which Playwright projects are measured and repeated in perf mode (D-04, D-13, D-22; behaviour: 04-REQ-18). 'auto': projects whose effective browser is Chromium (use.browserName, else use.defaultBrowserType from a device descriptor, else chromium; chrome/msedge channels count as Chromium) and which are neither a dependency nor a teardown of another project. A list: exactly these project names; a listed project that is also a dependency of another listed project is measured and repeated too.
31
+ * Only tests whose title or tags match this regular expression run in perf mode, e.g. '@perf' (03-REQ-25). Applied case-insensitively to the projects that are measured (all but setup and teardown projects, 04-REQ-18); setup and teardown projects run in full. null: all tests.
32
32
  */
33
- projects?: 'auto' | [string, ...string[]];
33
+ grep?: null | string;
34
34
  /**
35
- * Reporters kept in perf mode by name, as in the Playwright reporter config (e.g. 'junit', 'allure-playwright'). By default withPerf() keeps only the console reporters (list, line, dot, github) and the package reporter (D-23, 04-REQ-32).
35
+ * Reporters kept in perf mode by name, as in the Playwright reporter config (e.g. 'junit', 'allure-playwright'). By default withPerf() keeps only the console reporters line, dot and github (list becomes dot; name list here to keep it) and the package reporter (D-23, 04-REQ-32).
36
36
  */
37
37
  keepReporters?: string[];
38
+ /**
39
+ * Sets use.launchOptions.slowMo to 0 in every measured project in perf mode (03-REQ-27, D-45). slowMo delays every browser action and distorts the measured times; off by default because some tests are unstable without it. false: slowMo stays and perf mode warns about it (CONFIG_SLOW_MO).
40
+ */
41
+ overrideSlowMo?: boolean;
38
42
  };
39
43
  /**
40
44
  * What the collector measures (05).
41
45
  */
42
46
  measure?: {
47
+ /**
48
+ * Requests the browser makes to the backend and calls of the request fixture, page.request and context.request (keys with the prefix 'request '), as keys of kind 'api' (05, 15, 03-REQ-28). false: no request is measured, the api thresholds file is neither read nor written, and only test.step durations are measured; measure.api and measure.steps cannot both be off.
49
+ */
50
+ api?: boolean;
43
51
  /**
44
52
  * Playwright resource types that are measured. WebSocket traffic is not available as Request events in Playwright and cannot be measured (05).
45
53
  *
@@ -81,6 +89,58 @@ interface PackageConfig {
81
89
  * @minItems 1
82
90
  */
83
91
  successStatuses?: [string, ...string[]];
92
+ /**
93
+ * Durations of test.step steps as keys of kind 'step' (06). true (default) enables with defaults, false disables, an object enables with settings (03-REQ-18).
94
+ */
95
+ steps?: boolean | {
96
+ /**
97
+ * Default true when an object is given.
98
+ */
99
+ enabled?: boolean;
100
+ /**
101
+ * When not empty, only steps whose step key part matches at least one pattern give samples (06-REQ-22).
102
+ *
103
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
104
+ */
105
+ include?: (string | {
106
+ regex: string;
107
+ flags?: string;
108
+ })[];
109
+ /**
110
+ * Steps whose step key part matches any pattern give no samples; exclude wins over include.
111
+ *
112
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
113
+ */
114
+ exclude?: (string | {
115
+ regex: string;
116
+ flags?: string;
117
+ })[];
118
+ /**
119
+ * Deepest step level measured; deeper steps are included in their ancestor's time (06-REQ-21).
120
+ */
121
+ maxDepth?: number;
122
+ /**
123
+ * Playwright step categories measured (06-REQ-20). Steps of other categories are transparent for keys and depth.
124
+ *
125
+ * @minItems 1
126
+ */
127
+ categories?: [
128
+ 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook',
129
+ ...('test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook')[]
130
+ ];
131
+ /**
132
+ * 'step': one key per step path across tests; 'test': one key per test and step path (06-REQ-23).
133
+ */
134
+ groupBy?: 'step' | 'test';
135
+ /**
136
+ * false skips the key-stability rules (ids, dates, numbers); privacy rules always apply (06-REQ-35).
137
+ */
138
+ normalizeTitles?: boolean;
139
+ /**
140
+ * true replaces quoted values in step titles with :value; by default they stay in keys (06-D-26).
141
+ */
142
+ redactQuotedValues?: boolean;
143
+ };
84
144
  /**
85
145
  * How long the collector waits at test end for requests still in flight (05).
86
146
  */
@@ -91,7 +151,7 @@ interface PackageConfig {
91
151
  */
92
152
  keys?: {
93
153
  /**
94
- * Origin to label mapping, e.g. {"https://api.example.com": "api"}. The origin of Playwright use.baseURL gets the empty label unless mapped here. Other origins are labeled with their host.
154
+ * Origin to label mapping, e.g. {"https://api.example.com": "api"}. A key with * is a host pattern, e.g. "https://*.ci.example.com" (one * per host label, never across a dot); an exact entry wins over a pattern. The origin of Playwright use.baseURL gets the empty label unless mapped here. Other origins are labeled with their host.
95
155
  */
96
156
  origins?: {
97
157
  [k: string]: string;
@@ -114,6 +174,10 @@ interface PackageConfig {
114
174
  * Random-looking ids of at least 16 characters with a digit, a lowercase and an uppercase letter, e.g. nanoid (07-REQ-08).
115
175
  */
116
176
  mixed?: boolean;
177
+ /**
178
+ * Ids with a prefix: 2-5 capital letters, '-' and at least 3 digits (ORD-1000), or 1-8 lowercase letters, '_' and at least 2 digits or 8-32 letters and digits with a digit (inv_58) (07-REQ-08).
179
+ */
180
+ prefixed?: boolean;
117
181
  /**
118
182
  * E-mail addresses, replaced with ':email' (07-REQ-08).
119
183
  */
@@ -193,7 +257,7 @@ interface PackageConfig {
193
257
  /**
194
258
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
195
259
  */
196
- custom?: number;
260
+ step?: number;
197
261
  };
198
262
  };
199
263
  /**
@@ -223,7 +287,7 @@ interface PackageConfig {
223
287
  /**
224
288
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
225
289
  */
226
- custom?: number;
290
+ step?: number;
227
291
  };
228
292
  /**
229
293
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -283,7 +347,7 @@ interface PackageConfig {
283
347
  /**
284
348
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
285
349
  */
286
- custom?: number;
350
+ step?: number;
287
351
  };
288
352
  };
289
353
  };
@@ -309,7 +373,7 @@ interface PackageConfig {
309
373
  */
310
374
  medianFactor?: number;
311
375
  };
312
- custom?: {
376
+ step?: {
313
377
  /**
314
378
  * Lower clamp of derived T.
315
379
  */
@@ -360,7 +424,7 @@ interface PackageConfig {
360
424
  /**
361
425
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
362
426
  */
363
- custom?: number;
427
+ step?: number;
364
428
  };
365
429
  };
366
430
  /**
@@ -411,7 +475,7 @@ interface PackageConfig {
411
475
  /**
412
476
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
413
477
  */
414
- custom?: number;
478
+ step?: number;
415
479
  };
416
480
  };
417
481
  };
@@ -428,7 +492,7 @@ interface PackageConfig {
428
492
  */
429
493
  minSamples?: number;
430
494
  /**
431
- * Request statuses counted as errors by the 'errors' rule (08, 09): a class like '5xx', an exact code like '429', FAILED (request failed without a response, not aborted), ABORTED (cancelled by the browser, e.g. on navigation), PENDING (still in flight at test end). Custom measurements: outcomes error and unfinished are always errors.
495
+ * Request statuses counted as errors by the 'errors' rule (08, 09): a class like '5xx', an exact code like '429', FAILED (request failed without a response, not aborted), ABORTED (cancelled by the browser, e.g. on navigation), PENDING (still in flight at test end).
432
496
  */
433
497
  statuses?: string[];
434
498
  /**
@@ -442,7 +506,7 @@ interface PackageConfig {
442
506
  /**
443
507
  * Value between 0 and 1 inclusive. The thresholds generator writes at most 3 decimal places (02-REQ-08); hand-written values with more decimals are accepted (02-D-11).
444
508
  */
445
- custom?: number;
509
+ step?: number;
446
510
  };
447
511
  /**
448
512
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -479,10 +543,6 @@ interface PackageConfig {
479
543
  * 'block': violations on keys evaluated with default thresholds can fail the run; 'warn': they only warn.
480
544
  */
481
545
  defaultThresholds?: 'block' | 'warn';
482
- /**
483
- * Report violations but never fail the run.
484
- */
485
- warnOnly?: boolean;
486
546
  /**
487
547
  * Highest share of failed test executions (unexpected / executed, skipped excluded) for which the run result is still trustworthy. Above it the run ends with tool error TESTS_FAILED_TOO_MANY (exit code 3, 09). Failed tests below it are a warning only: in perf mode the performance result decides (00, chapter 11).
488
548
  */
@@ -492,12 +552,16 @@ interface PackageConfig {
492
552
  * Thresholds files and derivation (10).
493
553
  */
494
554
  thresholds?: {
555
+ /**
556
+ * Headroom preset for derived thresholds (D-41, 10-REQ-23): sets the defaults of every checks.*.margin; margin fields set explicitly win. strict: small headroom, catches smaller regressions, more false alarms on a noisy environment. normal: recommended start. loose: large headroom, only clear regressions, for shared noisy environments.
557
+ */
558
+ preset?: 'strict' | 'normal' | 'loose';
495
559
  /**
496
560
  * Directory of thresholds files, relative to the Playwright config directory.
497
561
  */
498
562
  dir?: string;
499
563
  /**
500
- * File name prefix; files are <prefix>.<kind>[.<env>].json.
564
+ * File name prefix; files are <prefix>[.steps][.<env>].json.
501
565
  */
502
566
  filePrefix?: string;
503
567
  /**
@@ -531,7 +595,7 @@ interface PackageConfig {
531
595
  */
532
596
  report?: {
533
597
  /**
534
- * Directory of report.json and report.html, relative to the Playwright config directory.
598
+ * Directory of report.json and report.html, relative to the Playwright config directory. Emptied when the first test of a test or thresholds run starts; never the project directory or a folder with thresholds files.
535
599
  */
536
600
  dir?: string;
537
601
  /**
@@ -570,6 +634,24 @@ type Override<T, U> = {
570
634
  [K in keyof T]: K extends keyof U ? U[K] extends Whole ? U[K] : U[K] extends object ? Override<T[K], U[K]> : U[K] : T[K];
571
635
  };
572
636
 
637
+ type StepCategory = 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook';
638
+ type JsonPattern = string | {
639
+ regex: string;
640
+ flags?: string;
641
+ };
642
+ /** measure.steps after resolution, in JSON form (snapshot in the run report). */
643
+ interface StepsSettingsJson {
644
+ enabled: boolean;
645
+ include: JsonPattern[];
646
+ exclude: JsonPattern[];
647
+ maxDepth: number;
648
+ /** Non-empty (03-REQ-18). */
649
+ categories: [StepCategory, ...StepCategory[]];
650
+ groupBy: 'step' | 'test';
651
+ normalizeTitles: boolean;
652
+ redactQuotedValues: boolean;
653
+ }
654
+
573
655
  /** JSON form of the package config: a JSON config file or the snapshot in the run report. */
574
656
  type PerfConfigJson = PackageConfig;
575
657
  /** A string matches as a case-sensitive substring; RegExp and { regex, flags } are regexes. */
@@ -591,12 +673,17 @@ type PerfConfigInput = DeepPartial<Override<PerfConfigJson, {
591
673
  measure: {
592
674
  include: UrlPattern[];
593
675
  exclude: UrlPattern[];
676
+ steps: boolean | (Omit<StepsSettingsJson, 'include' | 'exclude'> & StepPatternsInput);
594
677
  };
595
678
  keys: {
596
679
  extraIdPatterns: UrlPattern[];
597
680
  keyBuilder: KeyBuilder;
598
681
  };
599
682
  }>>;
683
+ interface StepPatternsInput {
684
+ include: UrlPattern[];
685
+ exclude: UrlPattern[];
686
+ }
600
687
  /** Every property required, recursively; arrays and tuples are kept as they are. */
601
688
  type Complete<T> = T extends readonly unknown[] ? T : T extends object ? {
602
689
  [K in keyof T]-?: Complete<Exclude<T[K], undefined>>;
@@ -606,7 +693,10 @@ type CompleteJson = Complete<Omit<PerfConfigJson, '$schema'>>;
606
693
  * JSON form of a fully resolved config: every option has a value. keys.keyBuilder is present
607
694
  * ("[function]") only when a key builder function was configured (02-REQ-17).
608
695
  */
609
- type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
696
+ type ResolvedConfigJson = Omit<CompleteJson, 'keys' | 'measure'> & {
697
+ measure: Omit<CompleteJson['measure'], 'steps'> & {
698
+ steps: StepsSettingsJson;
699
+ };
610
700
  keys: Omit<CompleteJson['keys'], 'keyBuilder'> & {
611
701
  keyBuilder?: '[function]';
612
702
  };
@@ -615,15 +705,21 @@ type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
615
705
  type ResolvedUrlPattern = string | RegExp;
616
706
  /** Fully resolved config: all options filled in, patterns compiled (03, chapter 5). */
617
707
  type ResolvedConfig = Omit<ResolvedConfigJson, 'measure' | 'keys'> & {
618
- measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude'> & {
708
+ measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude' | 'steps'> & {
619
709
  include: ResolvedUrlPattern[];
620
710
  exclude: ResolvedUrlPattern[];
711
+ steps: ResolvedStepsSettings;
621
712
  };
622
713
  keys: Omit<ResolvedConfigJson['keys'], 'extraIdPatterns' | 'keyBuilder'> & {
623
714
  extraIdPatterns: ResolvedUrlPattern[];
624
715
  keyBuilder: KeyBuilder | undefined;
625
716
  };
626
717
  };
718
+ /** measure.steps after resolution: full object, patterns compiled (03-REQ-18). */
719
+ type ResolvedStepsSettings = Omit<StepsSettingsJson, 'include' | 'exclude'> & {
720
+ include: ResolvedUrlPattern[];
721
+ exclude: ResolvedUrlPattern[];
722
+ };
627
723
 
628
724
  /** Returns `config` unchanged; it only gives editor type hints in a config file (D-15). */
629
725
  declare function definePerfConfig(config: PerfConfigInput): PerfConfigInput;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { definePerfConfig, perfDefaults } from './chunk-L5C63HEF.js';
1
+ export { definePerfConfig, perfDefaults } from './chunk-CISGJCFW.js';
@@ -0,0 +1,17 @@
1
+ import { BrowserContext, APIRequestContext } from '@playwright/test';
2
+
3
+ interface PerfApi {
4
+ /** Tracks a browser context created in this test or in a test-scoped fixture, until test end. */
5
+ track(context: BrowserContext): void;
6
+ /**
7
+ * Measures the calls of an APIRequestContext from playwright.request.newContext() (15-REQ-03).
8
+ * Does nothing outside perf mode or in projects that are not measured.
9
+ */
10
+ trackRequestContext(requestContext: APIRequestContext): void;
11
+ }
12
+ /** Fixtures added by withPerfFixtures(). */
13
+ interface PerfFixtures {
14
+ perf: PerfApi;
15
+ }
16
+
17
+ export type { PerfFixtures as P, PerfApi as a };