playwright-performance-regression 0.1.0-next.0 → 0.1.0-next.3

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 (40) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +73 -52
  3. package/dist/{chunk-GCA73FFP.cjs → chunk-2JO5HVPC.cjs} +351 -44
  4. package/dist/{chunk-R2NPYGB7.cjs → chunk-44ASXVQN.cjs} +96 -198
  5. package/dist/{chunk-HES6BVZT.js → chunk-AQ2XKYNV.js} +349 -47
  6. package/dist/chunk-BAOTUUTV.cjs +611 -0
  7. package/dist/chunk-DX36GFOZ.js +558 -0
  8. package/dist/chunk-LTRHMBVY.js +5592 -0
  9. package/dist/{chunk-UTTU4FUC.js → chunk-MUZFQKGQ.js} +82 -184
  10. package/dist/cli.js +3500 -1157
  11. package/dist/config.cjs +91 -44
  12. package/dist/config.d.cts +4 -2
  13. package/dist/config.d.ts +4 -2
  14. package/dist/config.js +84 -37
  15. package/dist/fixture.cjs +5 -5
  16. package/dist/fixture.d.cts +2 -2
  17. package/dist/fixture.d.ts +2 -2
  18. package/dist/fixture.js +3 -3
  19. package/dist/index.cjs +3 -3
  20. package/dist/index.d.cts +110 -22
  21. package/dist/index.d.ts +110 -22
  22. package/dist/index.js +1 -1
  23. package/dist/perf-api-Rm1h1O_-.d.cts +12 -0
  24. package/dist/perf-api-Rm1h1O_-.d.ts +12 -0
  25. package/dist/reporter.cjs +5204 -1209
  26. package/dist/reporter.js +2035 -254
  27. package/dist/test.cjs +4 -4
  28. package/dist/test.js +3 -3
  29. package/package.json +5 -3
  30. package/schemas/common.schema.json +2 -2
  31. package/schemas/config.schema.json +57 -21
  32. package/schemas/outcome.schema.json +1 -1
  33. package/schemas/run-report.schema.json +534 -19
  34. package/schemas/samples.schema.json +4 -39
  35. package/schemas/thresholds.schema.json +1 -1
  36. package/dist/chunk-6AB42SPF.js +0 -254
  37. package/dist/chunk-JEHUFIY3.js +0 -3390
  38. package/dist/chunk-LV3O2BAT.cjs +0 -319
  39. package/dist/perf-api-V4PeHVE0.d.cts +0 -22
  40. package/dist/perf-api-V4PeHVE0.d.ts +0 -22
package/dist/index.d.cts CHANGED
@@ -15,24 +15,28 @@ interface PackageConfig {
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 / --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
+ * Which Playwright projects are measured in perf mode (D-13, D-22, D-39; 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 too.
32
32
  */
33
33
  projects?: 'auto' | [string, ...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
+ * 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 measured projects only; their setup and teardown projects run in full. null: all tests.
36
+ */
37
+ grep?: null | string;
38
+ /**
39
+ * 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
40
  */
37
41
  keepReporters?: string[];
38
42
  };
@@ -81,6 +85,58 @@ interface PackageConfig {
81
85
  * @minItems 1
82
86
  */
83
87
  successStatuses?: [string, ...string[]];
88
+ /**
89
+ * Durations of test.step steps as keys of kind 'step' (06). false (default) disables, true enables with defaults, an object enables with settings (03-REQ-18).
90
+ */
91
+ steps?: boolean | {
92
+ /**
93
+ * Default true when an object is given.
94
+ */
95
+ enabled?: boolean;
96
+ /**
97
+ * When not empty, only steps whose step key part matches at least one pattern give samples (06-REQ-22).
98
+ *
99
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
100
+ */
101
+ include?: (string | {
102
+ regex: string;
103
+ flags?: string;
104
+ })[];
105
+ /**
106
+ * Steps whose step key part matches any pattern give no samples; exclude wins over include.
107
+ *
108
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
109
+ */
110
+ exclude?: (string | {
111
+ regex: string;
112
+ flags?: string;
113
+ })[];
114
+ /**
115
+ * Deepest step level measured; deeper steps are included in their ancestor's time (06-REQ-21).
116
+ */
117
+ maxDepth?: number;
118
+ /**
119
+ * Playwright step categories measured (06-REQ-20). Steps of other categories are transparent for keys and depth.
120
+ *
121
+ * @minItems 1
122
+ */
123
+ categories?: [
124
+ 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook',
125
+ ...('test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook')[]
126
+ ];
127
+ /**
128
+ * 'step': one key per step path across tests; 'test': one key per test and step path (06-REQ-23).
129
+ */
130
+ groupBy?: 'step' | 'test';
131
+ /**
132
+ * false skips the key-stability rules (ids, dates, numbers); privacy rules always apply (06-REQ-35).
133
+ */
134
+ normalizeTitles?: boolean;
135
+ /**
136
+ * true replaces quoted values in step titles with :value; by default they stay in keys (06-D-26).
137
+ */
138
+ redactQuotedValues?: boolean;
139
+ };
84
140
  /**
85
141
  * How long the collector waits at test end for requests still in flight (05).
86
142
  */
@@ -91,7 +147,7 @@ interface PackageConfig {
91
147
  */
92
148
  keys?: {
93
149
  /**
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.
150
+ * 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
151
  */
96
152
  origins?: {
97
153
  [k: string]: string;
@@ -193,7 +249,7 @@ interface PackageConfig {
193
249
  /**
194
250
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
195
251
  */
196
- custom?: number;
252
+ step?: number;
197
253
  };
198
254
  };
199
255
  /**
@@ -223,7 +279,7 @@ interface PackageConfig {
223
279
  /**
224
280
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
225
281
  */
226
- custom?: number;
282
+ step?: number;
227
283
  };
228
284
  /**
229
285
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -283,7 +339,7 @@ interface PackageConfig {
283
339
  /**
284
340
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
285
341
  */
286
- custom?: number;
342
+ step?: number;
287
343
  };
288
344
  };
289
345
  };
@@ -309,7 +365,7 @@ interface PackageConfig {
309
365
  */
310
366
  medianFactor?: number;
311
367
  };
312
- custom?: {
368
+ step?: {
313
369
  /**
314
370
  * Lower clamp of derived T.
315
371
  */
@@ -360,7 +416,7 @@ interface PackageConfig {
360
416
  /**
361
417
  * 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
418
  */
363
- custom?: number;
419
+ step?: number;
364
420
  };
365
421
  };
366
422
  /**
@@ -411,7 +467,7 @@ interface PackageConfig {
411
467
  /**
412
468
  * 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
469
  */
414
- custom?: number;
470
+ step?: number;
415
471
  };
416
472
  };
417
473
  };
@@ -428,7 +484,7 @@ interface PackageConfig {
428
484
  */
429
485
  minSamples?: number;
430
486
  /**
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.
487
+ * 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
488
  */
433
489
  statuses?: string[];
434
490
  /**
@@ -442,7 +498,7 @@ interface PackageConfig {
442
498
  /**
443
499
  * 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
500
  */
445
- custom?: number;
501
+ step?: number;
446
502
  };
447
503
  /**
448
504
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -479,10 +535,6 @@ interface PackageConfig {
479
535
  * 'block': violations on keys evaluated with default thresholds can fail the run; 'warn': they only warn.
480
536
  */
481
537
  defaultThresholds?: 'block' | 'warn';
482
- /**
483
- * Report violations but never fail the run.
484
- */
485
- warnOnly?: boolean;
486
538
  /**
487
539
  * 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
540
  */
@@ -492,12 +544,16 @@ interface PackageConfig {
492
544
  * Thresholds files and derivation (10).
493
545
  */
494
546
  thresholds?: {
547
+ /**
548
+ * 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.
549
+ */
550
+ preset?: 'strict' | 'normal' | 'loose';
495
551
  /**
496
552
  * Directory of thresholds files, relative to the Playwright config directory.
497
553
  */
498
554
  dir?: string;
499
555
  /**
500
- * File name prefix; files are <prefix>.<kind>[.<env>].json.
556
+ * File name prefix; files are <prefix>[.steps][.<env>].json.
501
557
  */
502
558
  filePrefix?: string;
503
559
  /**
@@ -570,6 +626,24 @@ type Override<T, U> = {
570
626
  [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
627
  };
572
628
 
629
+ type StepCategory = 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook';
630
+ type JsonPattern = string | {
631
+ regex: string;
632
+ flags?: string;
633
+ };
634
+ /** measure.steps after resolution, in JSON form (snapshot in the run report). */
635
+ interface StepsSettingsJson {
636
+ enabled: boolean;
637
+ include: JsonPattern[];
638
+ exclude: JsonPattern[];
639
+ maxDepth: number;
640
+ /** Non-empty (03-REQ-18). */
641
+ categories: [StepCategory, ...StepCategory[]];
642
+ groupBy: 'step' | 'test';
643
+ normalizeTitles: boolean;
644
+ redactQuotedValues: boolean;
645
+ }
646
+
573
647
  /** JSON form of the package config: a JSON config file or the snapshot in the run report. */
574
648
  type PerfConfigJson = PackageConfig;
575
649
  /** A string matches as a case-sensitive substring; RegExp and { regex, flags } are regexes. */
@@ -591,12 +665,17 @@ type PerfConfigInput = DeepPartial<Override<PerfConfigJson, {
591
665
  measure: {
592
666
  include: UrlPattern[];
593
667
  exclude: UrlPattern[];
668
+ steps: boolean | (Omit<StepsSettingsJson, 'include' | 'exclude'> & StepPatternsInput);
594
669
  };
595
670
  keys: {
596
671
  extraIdPatterns: UrlPattern[];
597
672
  keyBuilder: KeyBuilder;
598
673
  };
599
674
  }>>;
675
+ interface StepPatternsInput {
676
+ include: UrlPattern[];
677
+ exclude: UrlPattern[];
678
+ }
600
679
  /** Every property required, recursively; arrays and tuples are kept as they are. */
601
680
  type Complete<T> = T extends readonly unknown[] ? T : T extends object ? {
602
681
  [K in keyof T]-?: Complete<Exclude<T[K], undefined>>;
@@ -606,7 +685,10 @@ type CompleteJson = Complete<Omit<PerfConfigJson, '$schema'>>;
606
685
  * JSON form of a fully resolved config: every option has a value. keys.keyBuilder is present
607
686
  * ("[function]") only when a key builder function was configured (02-REQ-17).
608
687
  */
609
- type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
688
+ type ResolvedConfigJson = Omit<CompleteJson, 'keys' | 'measure'> & {
689
+ measure: Omit<CompleteJson['measure'], 'steps'> & {
690
+ steps: StepsSettingsJson;
691
+ };
610
692
  keys: Omit<CompleteJson['keys'], 'keyBuilder'> & {
611
693
  keyBuilder?: '[function]';
612
694
  };
@@ -615,15 +697,21 @@ type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
615
697
  type ResolvedUrlPattern = string | RegExp;
616
698
  /** Fully resolved config: all options filled in, patterns compiled (03, chapter 5). */
617
699
  type ResolvedConfig = Omit<ResolvedConfigJson, 'measure' | 'keys'> & {
618
- measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude'> & {
700
+ measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude' | 'steps'> & {
619
701
  include: ResolvedUrlPattern[];
620
702
  exclude: ResolvedUrlPattern[];
703
+ steps: ResolvedStepsSettings;
621
704
  };
622
705
  keys: Omit<ResolvedConfigJson['keys'], 'extraIdPatterns' | 'keyBuilder'> & {
623
706
  extraIdPatterns: ResolvedUrlPattern[];
624
707
  keyBuilder: KeyBuilder | undefined;
625
708
  };
626
709
  };
710
+ /** measure.steps after resolution: full object, patterns compiled (03-REQ-18). */
711
+ type ResolvedStepsSettings = Omit<StepsSettingsJson, 'include' | 'exclude'> & {
712
+ include: ResolvedUrlPattern[];
713
+ exclude: ResolvedUrlPattern[];
714
+ };
627
715
 
628
716
  /** Returns `config` unchanged; it only gives editor type hints in a config file (D-15). */
629
717
  declare function definePerfConfig(config: PerfConfigInput): PerfConfigInput;
package/dist/index.d.ts CHANGED
@@ -15,24 +15,28 @@ interface PackageConfig {
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 / --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
+ * Which Playwright projects are measured in perf mode (D-13, D-22, D-39; 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 too.
32
32
  */
33
33
  projects?: 'auto' | [string, ...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
+ * 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 measured projects only; their setup and teardown projects run in full. null: all tests.
36
+ */
37
+ grep?: null | string;
38
+ /**
39
+ * 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
40
  */
37
41
  keepReporters?: string[];
38
42
  };
@@ -81,6 +85,58 @@ interface PackageConfig {
81
85
  * @minItems 1
82
86
  */
83
87
  successStatuses?: [string, ...string[]];
88
+ /**
89
+ * Durations of test.step steps as keys of kind 'step' (06). false (default) disables, true enables with defaults, an object enables with settings (03-REQ-18).
90
+ */
91
+ steps?: boolean | {
92
+ /**
93
+ * Default true when an object is given.
94
+ */
95
+ enabled?: boolean;
96
+ /**
97
+ * When not empty, only steps whose step key part matches at least one pattern give samples (06-REQ-22).
98
+ *
99
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
100
+ */
101
+ include?: (string | {
102
+ regex: string;
103
+ flags?: string;
104
+ })[];
105
+ /**
106
+ * Steps whose step key part matches any pattern give no samples; exclude wins over include.
107
+ *
108
+ * Items: A string matches as a case-sensitive substring of the full URL; {regex, flags} is a JavaScript regular expression.
109
+ */
110
+ exclude?: (string | {
111
+ regex: string;
112
+ flags?: string;
113
+ })[];
114
+ /**
115
+ * Deepest step level measured; deeper steps are included in their ancestor's time (06-REQ-21).
116
+ */
117
+ maxDepth?: number;
118
+ /**
119
+ * Playwright step categories measured (06-REQ-20). Steps of other categories are transparent for keys and depth.
120
+ *
121
+ * @minItems 1
122
+ */
123
+ categories?: [
124
+ 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook',
125
+ ...('test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook')[]
126
+ ];
127
+ /**
128
+ * 'step': one key per step path across tests; 'test': one key per test and step path (06-REQ-23).
129
+ */
130
+ groupBy?: 'step' | 'test';
131
+ /**
132
+ * false skips the key-stability rules (ids, dates, numbers); privacy rules always apply (06-REQ-35).
133
+ */
134
+ normalizeTitles?: boolean;
135
+ /**
136
+ * true replaces quoted values in step titles with :value; by default they stay in keys (06-D-26).
137
+ */
138
+ redactQuotedValues?: boolean;
139
+ };
84
140
  /**
85
141
  * How long the collector waits at test end for requests still in flight (05).
86
142
  */
@@ -91,7 +147,7 @@ interface PackageConfig {
91
147
  */
92
148
  keys?: {
93
149
  /**
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.
150
+ * 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
151
  */
96
152
  origins?: {
97
153
  [k: string]: string;
@@ -193,7 +249,7 @@ interface PackageConfig {
193
249
  /**
194
250
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
195
251
  */
196
- custom?: number;
252
+ step?: number;
197
253
  };
198
254
  };
199
255
  /**
@@ -223,7 +279,7 @@ interface PackageConfig {
223
279
  /**
224
280
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
225
281
  */
226
- custom?: number;
282
+ step?: number;
227
283
  };
228
284
  /**
229
285
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -283,7 +339,7 @@ interface PackageConfig {
283
339
  /**
284
340
  * Threshold limit in whole milliseconds, rounded up (02-REQ-08).
285
341
  */
286
- custom?: number;
342
+ step?: number;
287
343
  };
288
344
  };
289
345
  };
@@ -309,7 +365,7 @@ interface PackageConfig {
309
365
  */
310
366
  medianFactor?: number;
311
367
  };
312
- custom?: {
368
+ step?: {
313
369
  /**
314
370
  * Lower clamp of derived T.
315
371
  */
@@ -360,7 +416,7 @@ interface PackageConfig {
360
416
  /**
361
417
  * 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
418
  */
363
- custom?: number;
419
+ step?: number;
364
420
  };
365
421
  };
366
422
  /**
@@ -411,7 +467,7 @@ interface PackageConfig {
411
467
  /**
412
468
  * 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
469
  */
414
- custom?: number;
470
+ step?: number;
415
471
  };
416
472
  };
417
473
  };
@@ -428,7 +484,7 @@ interface PackageConfig {
428
484
  */
429
485
  minSamples?: number;
430
486
  /**
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.
487
+ * 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
488
  */
433
489
  statuses?: string[];
434
490
  /**
@@ -442,7 +498,7 @@ interface PackageConfig {
442
498
  /**
443
499
  * 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
500
  */
445
- custom?: number;
501
+ step?: number;
446
502
  };
447
503
  /**
448
504
  * Headroom added to the source run value when deriving this limit (10, chapter 5).
@@ -479,10 +535,6 @@ interface PackageConfig {
479
535
  * 'block': violations on keys evaluated with default thresholds can fail the run; 'warn': they only warn.
480
536
  */
481
537
  defaultThresholds?: 'block' | 'warn';
482
- /**
483
- * Report violations but never fail the run.
484
- */
485
- warnOnly?: boolean;
486
538
  /**
487
539
  * 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
540
  */
@@ -492,12 +544,16 @@ interface PackageConfig {
492
544
  * Thresholds files and derivation (10).
493
545
  */
494
546
  thresholds?: {
547
+ /**
548
+ * 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.
549
+ */
550
+ preset?: 'strict' | 'normal' | 'loose';
495
551
  /**
496
552
  * Directory of thresholds files, relative to the Playwright config directory.
497
553
  */
498
554
  dir?: string;
499
555
  /**
500
- * File name prefix; files are <prefix>.<kind>[.<env>].json.
556
+ * File name prefix; files are <prefix>[.steps][.<env>].json.
501
557
  */
502
558
  filePrefix?: string;
503
559
  /**
@@ -570,6 +626,24 @@ type Override<T, U> = {
570
626
  [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
627
  };
572
628
 
629
+ type StepCategory = 'test.step' | 'expect' | 'pw:api' | 'fixture' | 'hook';
630
+ type JsonPattern = string | {
631
+ regex: string;
632
+ flags?: string;
633
+ };
634
+ /** measure.steps after resolution, in JSON form (snapshot in the run report). */
635
+ interface StepsSettingsJson {
636
+ enabled: boolean;
637
+ include: JsonPattern[];
638
+ exclude: JsonPattern[];
639
+ maxDepth: number;
640
+ /** Non-empty (03-REQ-18). */
641
+ categories: [StepCategory, ...StepCategory[]];
642
+ groupBy: 'step' | 'test';
643
+ normalizeTitles: boolean;
644
+ redactQuotedValues: boolean;
645
+ }
646
+
573
647
  /** JSON form of the package config: a JSON config file or the snapshot in the run report. */
574
648
  type PerfConfigJson = PackageConfig;
575
649
  /** A string matches as a case-sensitive substring; RegExp and { regex, flags } are regexes. */
@@ -591,12 +665,17 @@ type PerfConfigInput = DeepPartial<Override<PerfConfigJson, {
591
665
  measure: {
592
666
  include: UrlPattern[];
593
667
  exclude: UrlPattern[];
668
+ steps: boolean | (Omit<StepsSettingsJson, 'include' | 'exclude'> & StepPatternsInput);
594
669
  };
595
670
  keys: {
596
671
  extraIdPatterns: UrlPattern[];
597
672
  keyBuilder: KeyBuilder;
598
673
  };
599
674
  }>>;
675
+ interface StepPatternsInput {
676
+ include: UrlPattern[];
677
+ exclude: UrlPattern[];
678
+ }
600
679
  /** Every property required, recursively; arrays and tuples are kept as they are. */
601
680
  type Complete<T> = T extends readonly unknown[] ? T : T extends object ? {
602
681
  [K in keyof T]-?: Complete<Exclude<T[K], undefined>>;
@@ -606,7 +685,10 @@ type CompleteJson = Complete<Omit<PerfConfigJson, '$schema'>>;
606
685
  * JSON form of a fully resolved config: every option has a value. keys.keyBuilder is present
607
686
  * ("[function]") only when a key builder function was configured (02-REQ-17).
608
687
  */
609
- type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
688
+ type ResolvedConfigJson = Omit<CompleteJson, 'keys' | 'measure'> & {
689
+ measure: Omit<CompleteJson['measure'], 'steps'> & {
690
+ steps: StepsSettingsJson;
691
+ };
610
692
  keys: Omit<CompleteJson['keys'], 'keyBuilder'> & {
611
693
  keyBuilder?: '[function]';
612
694
  };
@@ -615,15 +697,21 @@ type ResolvedConfigJson = Omit<CompleteJson, 'keys'> & {
615
697
  type ResolvedUrlPattern = string | RegExp;
616
698
  /** Fully resolved config: all options filled in, patterns compiled (03, chapter 5). */
617
699
  type ResolvedConfig = Omit<ResolvedConfigJson, 'measure' | 'keys'> & {
618
- measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude'> & {
700
+ measure: Omit<ResolvedConfigJson['measure'], 'include' | 'exclude' | 'steps'> & {
619
701
  include: ResolvedUrlPattern[];
620
702
  exclude: ResolvedUrlPattern[];
703
+ steps: ResolvedStepsSettings;
621
704
  };
622
705
  keys: Omit<ResolvedConfigJson['keys'], 'extraIdPatterns' | 'keyBuilder'> & {
623
706
  extraIdPatterns: ResolvedUrlPattern[];
624
707
  keyBuilder: KeyBuilder | undefined;
625
708
  };
626
709
  };
710
+ /** measure.steps after resolution: full object, patterns compiled (03-REQ-18). */
711
+ type ResolvedStepsSettings = Omit<StepsSettingsJson, 'include' | 'exclude'> & {
712
+ include: ResolvedUrlPattern[];
713
+ exclude: ResolvedUrlPattern[];
714
+ };
627
715
 
628
716
  /** Returns `config` unchanged; it only gives editor type hints in a config file (D-15). */
629
717
  declare function definePerfConfig(config: PerfConfigInput): PerfConfigInput;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { definePerfConfig, perfDefaults } from './chunk-HES6BVZT.js';
1
+ export { definePerfConfig, perfDefaults } from './chunk-AQ2XKYNV.js';
@@ -0,0 +1,12 @@
1
+ import { BrowserContext } 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
+ /** Fixtures added by withPerfFixtures(). */
8
+ interface PerfFixtures {
9
+ perf: PerfApi;
10
+ }
11
+
12
+ export type { PerfFixtures as P, PerfApi as a };
@@ -0,0 +1,12 @@
1
+ import { BrowserContext } 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
+ /** Fixtures added by withPerfFixtures(). */
8
+ interface PerfFixtures {
9
+ perf: PerfApi;
10
+ }
11
+
12
+ export type { PerfFixtures as P, PerfApi as a };