pw-core 1.2.0 → 1.3.0

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 (86) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +777 -0
  4. package/dist/codegen/config/context-weights.d.ts +8 -0
  5. package/dist/codegen/config/context-weights.js +11 -0
  6. package/dist/codegen/config/ignored-attributes.d.ts +1 -0
  7. package/dist/codegen/config/ignored-attributes.js +4 -0
  8. package/dist/codegen/config/ignored-classes.d.ts +1 -0
  9. package/dist/codegen/config/ignored-classes.js +144 -0
  10. package/dist/codegen/config/ignored-values.d.ts +1 -0
  11. package/dist/codegen/config/ignored-values.js +4 -0
  12. package/dist/codegen/config/index.d.ts +29 -0
  13. package/dist/codegen/config/index.js +17 -0
  14. package/dist/codegen/config/strategy-order.d.ts +1 -0
  15. package/dist/codegen/config/strategy-order.js +18 -0
  16. package/dist/codegen/config/weights.d.ts +15 -0
  17. package/dist/codegen/config/weights.js +18 -0
  18. package/dist/codegen/floating-panel/client.d.ts +1 -0
  19. package/dist/codegen/floating-panel/client.js +248 -0
  20. package/dist/codegen/floating-panel/index.d.ts +4 -0
  21. package/dist/codegen/floating-panel/index.js +20 -0
  22. package/dist/codegen/floating-panel/manager.d.ts +19 -0
  23. package/dist/codegen/floating-panel/manager.js +90 -0
  24. package/dist/codegen/floating-panel/template.d.ts +2 -0
  25. package/dist/codegen/floating-panel/template.js +58 -0
  26. package/dist/codegen/floating-panel/types.d.ts +7 -0
  27. package/dist/codegen/floating-panel/types.js +2 -0
  28. package/dist/codegen/generator/action.validator.d.ts +5 -0
  29. package/dist/codegen/generator/action.validator.js +27 -0
  30. package/dist/codegen/generator/index.d.ts +13 -0
  31. package/dist/codegen/generator/index.js +724 -0
  32. package/dist/codegen/generator/locator.restricted.d.ts +36 -0
  33. package/dist/codegen/generator/locator.restricted.js +127 -0
  34. package/dist/codegen/generator/locator.validator.d.ts +8 -0
  35. package/dist/codegen/generator/locator.validator.js +38 -0
  36. package/dist/codegen/hover-tracker/client.d.ts +1 -0
  37. package/dist/codegen/hover-tracker/client.js +75 -0
  38. package/dist/codegen/hover-tracker/index.d.ts +3 -0
  39. package/dist/codegen/hover-tracker/index.js +19 -0
  40. package/dist/codegen/hover-tracker/manager.d.ts +11 -0
  41. package/dist/codegen/hover-tracker/manager.js +28 -0
  42. package/dist/codegen/hover-tracker/types.d.ts +3 -0
  43. package/dist/codegen/hover-tracker/types.js +2 -0
  44. package/dist/codegen/index.d.ts +35 -0
  45. package/dist/codegen/index.js +1147 -0
  46. package/dist/codegen/key-utils.d.ts +23 -0
  47. package/dist/codegen/key-utils.js +68 -0
  48. package/dist/codegen/scorer/base-score.d.ts +1 -0
  49. package/dist/codegen/scorer/base-score.js +7 -0
  50. package/dist/codegen/scorer/context-score.d.ts +2 -0
  51. package/dist/codegen/scorer/context-score.js +27 -0
  52. package/dist/codegen/scorer/index.d.ts +5 -0
  53. package/dist/codegen/scorer/index.js +23 -0
  54. package/dist/codegen/scorer/locator.ranking.d.ts +15 -0
  55. package/dist/codegen/scorer/locator.ranking.js +83 -0
  56. package/dist/codegen/scorer/semantic-score.d.ts +1 -0
  57. package/dist/codegen/scorer/semantic-score.js +47 -0
  58. package/dist/codegen/types.d.ts +35 -0
  59. package/dist/codegen/types.js +2 -0
  60. package/dist/component/table.js +14 -10
  61. package/dist/constants/methods.d.ts +2 -0
  62. package/dist/constants/methods.js +33 -0
  63. package/dist/constants/strategies.d.ts +2 -0
  64. package/dist/constants/strategies.js +47 -0
  65. package/dist/page/actions/locator-actions.js +15 -4
  66. package/dist/page/assertions/verify-chain.d.ts +39 -32
  67. package/dist/page/assertions/verify-chain.js +18 -4
  68. package/dist/page/assertions/verify-helpers.js +12 -3
  69. package/dist/page/config.d.ts +109 -71
  70. package/dist/page/config.js +10 -31
  71. package/dist/page/locators/dynamic-locator-resolver.js +29 -9
  72. package/dist/page/locators/resolver.d.ts +15 -15
  73. package/dist/page/locators/resolver.js +151 -32
  74. package/dist/page/registry.d.ts +43 -6
  75. package/dist/page/registry.js +90 -18
  76. package/dist/page/typed-page.d.ts +33 -29
  77. package/dist/page/typed-page.js +40 -11
  78. package/dist/page/types/proxy-methods.d.ts +69 -54
  79. package/dist/page/types/validation.d.ts +48 -1
  80. package/dist/page/utils/caller-location.js +13 -9
  81. package/dist/page/utils/formatter.js +6 -3
  82. package/dist/types/methods.d.ts +4 -0
  83. package/dist/types/methods.js +2 -0
  84. package/dist/types/strategies.d.ts +17 -0
  85. package/dist/types/strategies.js +2 -0
  86. package/package.json +8 -1
@@ -1,60 +1,75 @@
1
1
  import { Locator } from '@playwright/test';
2
- import type { PageKeys, ChainedKeys } from '../config';
3
- /**
4
- * Playwright Locator methods proxied onto the page object.
5
- * Each method resolves a config key (or Locator) as the first argument.
6
- *
7
- * @example
8
- * ```ts
9
- * await page.click('submit');
10
- * await page.fill('username', 'alice', { nth: 1 });
11
- * ```
12
- *
13
- * pw-core adds `nth` to options targets a specific match when multiple elements resolve.
14
- */
15
- type ProxyKeys = 'click' | 'dblclick' | 'hover' | 'focus' | 'blur' | 'check' | 'uncheck' | 'clear' | 'waitFor' | 'isChecked' | 'isDisabled' | 'isVisible' | 'textContent' | 'innerText' | 'allInnerTexts' | 'allTextContents' | 'count' | 'scrollIntoViewIfNeeded' | 'boundingBox' | 'press' | 'pressSequentially' | 'selectOption' | 'setInputFiles' | 'getAttribute';
16
- type ModifyProxyArgs<Args extends any[]> = Args extends [] ? [options?: {
17
- nth?: number;
18
- hasText?: string | RegExp;
19
- }] : Args extends [any, any?] ? [Args[0], (Exclude<Args[1], undefined> & {
20
- nth?: number;
21
- hasText?: string | RegExp;
22
- })?] : Args extends [any?] ? Exclude<Args[0], undefined> extends object ? [(Exclude<Args[0], undefined> & {
23
- nth?: number;
24
- hasText?: string | RegExp;
25
- })?] : [Exclude<Args[0], undefined>, options?: {
26
- nth?: number;
27
- hasText?: string | RegExp;
28
- }] : [options?: {
29
- nth?: number;
30
- hasText?: string | RegExp;
31
- }];
32
- type BaseProxyLocatorMethods<T> = {
33
- [K in keyof Locator as K extends ProxyKeys ? K : never]: (target: PageKeys<T> | ChainedKeys<T> | Locator, ...args: ModifyProxyArgs<Parameters<Locator[K]>>) => ReturnType<Locator[K]>;
34
- };
35
- /**
36
- * Playwright Locator methods proxied onto the page object.
37
- * Each method resolves a config key (or Locator) as the first argument.
38
- *
39
- * @example
40
- * ```ts
41
- * await page.click('submit');
42
- * await page.fill('username', 'alice', { nth: 1 });
43
- * ```
44
- *
45
- * pw-core adds `nth` and `hasText` to options — targets a specific match when multiple elements resolve.
46
- */
47
- export interface ProxyLocatorMethods<T> extends BaseProxyLocatorMethods<T> {
2
+ import type { PageKeys, CheckableLocatorKeys, CheckboxLocatorKeys, EditableLocatorKeys, SelectableLocatorKeys, ModifyOptionsForTarget } from '../config';
3
+ export interface ProxyLocatorMethods<T> {
4
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-click Locator.click} */
5
+ click<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['click']>[0]>): Promise<void>;
6
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-dblclick Locator.dblclick} */
7
+ dblclick<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['dblclick']>[0]>): Promise<void>;
8
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-hover Locator.hover} */
9
+ hover<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['hover']>[0]>): Promise<void>;
10
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-focus Locator.focus} */
11
+ focus<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['focus']>[0]>): Promise<void>;
12
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-blur Locator.blur} */
13
+ blur<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['blur']>[0]>): Promise<void>;
14
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-check Locator.check} */
15
+ check<Target extends CheckableLocatorKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['check']>[0]>): Promise<void>;
16
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-uncheck Locator.uncheck} */
17
+ uncheck<Target extends CheckboxLocatorKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['uncheck']>[0]>): Promise<void>;
18
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-clear Locator.clear} */
19
+ clear<Target extends EditableLocatorKeys<T> | (string & {}) | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['clear']>[0]>): Promise<void>;
20
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-wait-for Locator.waitFor} */
21
+ waitFor<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['waitFor']>[0]>): Promise<void>;
22
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-is-checked Locator.isChecked} */
23
+ isChecked<Target extends CheckableLocatorKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['isChecked']>[0]>): Promise<boolean>;
24
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-is-disabled Locator.isDisabled} */
25
+ isDisabled<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['isDisabled']>[0]>): Promise<boolean>;
26
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-is-visible Locator.isVisible} */
27
+ isVisible<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['isVisible']>[0]>): Promise<boolean>;
28
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-text-content Locator.textContent} */
29
+ textContent<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['textContent']>[0]>): Promise<string | null>;
30
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-inner-text Locator.innerText} */
31
+ innerText<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['innerText']>[0]>): Promise<string>;
32
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-all-inner-texts Locator.allInnerTexts} */
33
+ allInnerTexts<Target extends PageKeys<T> | Locator>(target: Target): Promise<string[]>;
34
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-all-text-contents Locator.allTextContents} */
35
+ allTextContents<Target extends PageKeys<T> | Locator>(target: Target): Promise<string[]>;
36
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-count Locator.count} */
37
+ count<Target extends PageKeys<T> | Locator>(target: Target): Promise<number>;
38
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-scroll-into-view-if-needed Locator.scrollIntoViewIfNeeded} */
39
+ scrollIntoViewIfNeeded<Target extends PageKeys<T> | Locator>(target: Target, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['scrollIntoViewIfNeeded']>[0]>): Promise<void>;
40
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-bounding-box Locator.boundingBox} */
41
+ boundingBox<Target extends PageKeys<T> | Locator>(target: Target): Promise<{
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ } | null>;
47
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-press Locator.press} */
48
+ press<Target extends EditableLocatorKeys<T> | (string & {}) | Locator>(target: Target, key: string, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['press']>[1]>): Promise<void>;
49
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-press-sequentially Locator.pressSequentially} */
50
+ pressSequentially<Target extends EditableLocatorKeys<T> | (string & {}) | Locator>(target: Target, value: string, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['pressSequentially']>[1]>): Promise<void>;
51
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-select-option Locator.selectOption} */
52
+ selectOption<Target extends SelectableLocatorKeys<T> | (string & {}) | Locator>(target: Target, values: string | string[] | {
53
+ value?: string;
54
+ label?: string;
55
+ index?: number;
56
+ } | null, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['selectOption']>[1]>): Promise<string[]>;
57
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-set-input-files Locator.setInputFiles} */
58
+ setInputFiles<Target extends PageKeys<T> | Locator>(target: Target, files: string | string[] | {
59
+ name: string;
60
+ mimeType: string;
61
+ buffer: Buffer;
62
+ } | {
63
+ name: string;
64
+ mimeType: string;
65
+ buffer: Buffer;
66
+ }[], options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['setInputFiles']>[1]>): Promise<void>;
67
+ /** @see {@link https://playwright.dev/docs/api/class-locator#locator-get-attribute Locator.getAttribute} */
68
+ getAttribute<Target extends PageKeys<T> | Locator>(target: Target, name: string, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['getAttribute']>[1]>): Promise<string | null>;
48
69
  /** @see {@link https://playwright.dev/docs/api/class-locator#locator-fill Locator.fill} */
49
- fill(target: PageKeys<T> | ChainedKeys<T> | Locator, value: string, options?: Parameters<Locator['fill']>[1] & {
50
- nth?: number;
51
- hasText?: string | RegExp;
70
+ fill<Target extends EditableLocatorKeys<T> | (string & {}) | Locator>(target: Target, value: string, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['fill']>[1]> & {
52
71
  mask?: boolean;
53
72
  }): Promise<void>;
54
73
  /** @see {@link https://playwright.dev/docs/api/class-locator#locator-drag-to Locator.dragTo} */
55
- dragTo(target: PageKeys<T> | ChainedKeys<T> | Locator, destination: PageKeys<T> | ChainedKeys<T> | Locator, options?: Parameters<Locator['dragTo']>[1] & {
56
- nth?: number;
57
- hasText?: string | RegExp;
58
- }): Promise<void>;
74
+ dragTo<Target extends PageKeys<T> | Locator>(target: Target, destination: PageKeys<T> | Locator, options?: ModifyOptionsForTarget<T, Target, Parameters<Locator['dragTo']>[1]>): Promise<void>;
59
75
  }
60
- export {};
@@ -18,5 +18,52 @@ export type MissingInTestId<TestId extends string, Placeholders extends string>
18
18
  * (e.g. on the wrong value or unknown key) instead of marking the entire object as invalid.
19
19
  */
20
20
  export type ValidateDynamicEntryProperties<Pattern extends string, Entry, TargetKey extends 'testId' | 'selector'> = {
21
- [Key in (keyof Entry | ExtractPlaceholders<Pattern> | TargetKey)]: Key extends TargetKey ? Entry extends Record<TargetKey, infer TPat> ? TPat extends string ? [MissingInTestId<TPat, ExtractPlaceholders<Pattern>>] extends [never] ? string : `Error: ${TargetKey} must contain all placeholder names` : `Error: ${TargetKey} must be a string` : `Error: Dynamic entry must include a ${TargetKey} property` : Key extends ExtractPlaceholders<Pattern> ? Key extends keyof Entry ? Entry[Key] extends readonly string[] ? readonly string[] : `Error: Placeholder key must be an array: ${Key & string}` : `Error: Missing placeholder key: ${Key & string}` : `Error: Only placeholder keys and '${TargetKey}' are allowed`;
21
+ [Key in keyof Entry | ExtractPlaceholders<Pattern> | TargetKey]: Key extends TargetKey ? Entry extends Record<TargetKey, infer TPat> ? TPat extends string ? [MissingInTestId<TPat, ExtractPlaceholders<Pattern>>] extends [never] ? [Exclude<ExtractPlaceholders<TPat>, ExtractPlaceholders<Pattern>>] extends [never] ? string : {
22
+ [P in `Error: ${TargetKey} contains unknown placeholder(s): ${Exclude<ExtractPlaceholders<TPat>, ExtractPlaceholders<Pattern>> & string}`]: never;
23
+ } : {
24
+ [P in `Error: ${TargetKey} must contain all placeholder names: missing ${MissingInTestId<TPat, ExtractPlaceholders<Pattern>> & string}`]: never;
25
+ } : {
26
+ [P in `Error: ${TargetKey} must be a string`]: never;
27
+ } : {
28
+ [P in `Error: Dynamic entry must include a ${TargetKey} property`]: never;
29
+ } : Key extends ExtractPlaceholders<Pattern> ? Key extends keyof Entry ? Entry[Key] extends readonly string[] ? readonly string[] : {
30
+ [P in `Error: Placeholder key must be an array: ${Key & string}`]: never;
31
+ } : {
32
+ [P in `Error: Missing placeholder key: ${Key & string}`]: never;
33
+ } : {
34
+ [P in `Error: Only placeholder keys and '${TargetKey}' are allowed`]: never;
35
+ };
36
+ };
37
+ /**
38
+ * Replaces every `{Name}` placeholder in `Pattern` with `Capitalize<Value>`
39
+ * where `Value` is drawn from the corresponding array in `Entry`.
40
+ * Template-literal unions distribute automatically, producing the full cartesian product.
41
+ */
42
+ export type ReplacePattern<Pattern extends string, Entry> = Pattern extends `${infer Before}{${infer Name}}${infer After}` ? Name extends keyof Entry ? Entry[Name] extends readonly string[] ? `${Before}${Capitalize<Entry[Name][number]>}${ReplacePattern<After, Entry> & string}` : never : never : Pattern;
43
+ /**
44
+ * Expands a dynamic key pattern into the union of all concrete (camelCased) keys.
45
+ */
46
+ export type ExpandDynamicKey<Pattern extends string, Entry> = Uncapitalize<ReplacePattern<Pattern, Entry>>;
47
+ /**
48
+ * Resolves every key in a testIds record:
49
+ * - string values → the key itself (static locator)
50
+ * - object values → the expanded dynamic key union
51
+ */
52
+ export type ResolvedTestIdKeys<I> = {
53
+ [K in keyof I & string]: I[K] extends string ? K : ExpandDynamicKey<K, I[K]>;
54
+ }[keyof I & string];
55
+ export type AllExpandedTestIdKeys<I> = {
56
+ [P in keyof I & string]: I[P] extends string ? P : ExpandDynamicKey<P, I[P]>;
57
+ }[keyof I & string];
58
+ export type AllOtherExpandedTestIdKeys<I, K extends keyof I> = {
59
+ [P in Exclude<keyof I, K> & string]: I[P] extends string ? P : ExpandDynamicKey<P, I[P]>;
60
+ }[Exclude<keyof I, K> & string];
61
+ export type ValidateTestIds<I, TargetKey extends 'testId' | 'selector', S> = {
62
+ [K in keyof I & string]: I[K] extends string ? K extends AllOtherExpandedTestIdKeys<I, K> | AllExpandedTestIdKeys<S> ? {
63
+ [P in `Error: Duplicate key "${K}" is defined in multiple entries`]: never;
64
+ } : string : ExpandDynamicKey<K, I[K]> & (AllOtherExpandedTestIdKeys<I, K> | AllExpandedTestIdKeys<S>) extends never ? K extends `${string}{${string}}${string}` ? HasDuplicatePlaceholders<K> extends true ? {
65
+ [P in 'Error: Pattern contains duplicate placeholders']: never;
66
+ } : ValidateDynamicEntryProperties<K, I[K], TargetKey> : I[K] : {
67
+ [P in `Error: Dynamic locator "${K}" expands to duplicate key(s): ${ExpandDynamicKey<K, I[K]> & (AllOtherExpandedTestIdKeys<I, K> | AllExpandedTestIdKeys<S>) & string}`]: never;
68
+ };
22
69
  };
@@ -6,7 +6,7 @@ exports.getCallerLocation = getCallerLocation;
6
6
  // directly to the user's project files instead of showing internal pw-core library paths.
7
7
  const originalPrepare = Error.prepareStackTrace;
8
8
  Error.prepareStackTrace = (err, stack) => {
9
- const filteredStack = stack.filter(frame => {
9
+ const filteredStack = stack.filter((frame) => {
10
10
  const file = frame.getFileName();
11
11
  if (!file)
12
12
  return true;
@@ -27,14 +27,18 @@ Error.prepareStackTrace = (err, stack) => {
27
27
  }
28
28
  }
29
29
  const errString = err.toString ? err.toString() : String(err);
30
- return errString + '\n' + filteredStack.map(frame => {
31
- try {
32
- return ' at ' + frame.toString();
33
- }
34
- catch {
35
- return ' at <unknown>';
36
- }
37
- }).join('\n');
30
+ return (errString +
31
+ '\n' +
32
+ filteredStack
33
+ .map((frame) => {
34
+ try {
35
+ return ' at ' + frame.toString();
36
+ }
37
+ catch {
38
+ return ' at <unknown>';
39
+ }
40
+ })
41
+ .join('\n'));
38
42
  };
39
43
  function getCallerLocation() {
40
44
  const originalPrepareStackTrace = Error.prepareStackTrace;
@@ -37,7 +37,10 @@ function formatStepDescription(methodName, target, args) {
37
37
  if (methodName === 'uncheck')
38
38
  return `Uncheck "${targetStr}"`;
39
39
  const formattedMethod = methodName.charAt(0).toUpperCase() + methodName.slice(1);
40
- const cleanArgs = args.filter(a => typeof a === 'string' || typeof a === 'number').map(a => `"${a}"`).join(', ');
40
+ const cleanArgs = args
41
+ .filter((a) => typeof a === 'string' || typeof a === 'number')
42
+ .map((a) => `"${a}"`)
43
+ .join(', ');
41
44
  return `${formattedMethod} "${targetStr}"${cleanArgs ? ' with ' + cleanArgs : ''}`;
42
45
  }
43
46
  function formatAssertionDescription(target, matcherName, isNegated, args) {
@@ -49,8 +52,8 @@ function formatAssertionDescription(target, matcherName, isNegated, args) {
49
52
  toBeEnabled: isNegated ? 'is not enabled' : 'is enabled',
50
53
  toBeDisabled: isNegated ? 'is not disabled' : 'is disabled',
51
54
  toBeChecked: isNegated ? 'is not checked' : 'is checked',
52
- toHaveText: (isNegated ? 'does not have text "' : 'has text "') + args.map(a => String(a)).join(', ') + '"',
53
- toContainText: (isNegated ? 'does not contain "' : 'contains "') + args.map(a => String(a)).join(', ') + '"',
55
+ toHaveText: (isNegated ? 'does not have text "' : 'has text "') + args.map((a) => String(a)).join(', ') + '"',
56
+ toContainText: (isNegated ? 'does not contain "' : 'contains "') + args.map((a) => String(a)).join(', ') + '"',
54
57
  toHaveCount: (isNegated ? 'does not have count of "' : 'has count of "') + args[0] + '"'
55
58
  };
56
59
  return `${prefix} ${matcherMap[matcherName] || `${isNegated ? 'not ' : ''}${matcherName}`}`;
@@ -0,0 +1,4 @@
1
+ import { zeroArgMethodsList, oneArgMethodsList } from '../constants/methods';
2
+ export type AllowedZeroArgMethods = (typeof zeroArgMethodsList)[number];
3
+ export type AllowedOneArgMethods = (typeof oneArgMethodsList)[number];
4
+ export type AllowedMethodKeys = AllowedZeroArgMethods | AllowedOneArgMethods;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import { rolesList, strategyList } from '../constants/strategies';
2
+ export type RoleType = (typeof rolesList)[number];
3
+ export type StrategyType = (typeof strategyList)[number];
4
+ export type PlaywrightRoleOptions = {
5
+ exact?: boolean;
6
+ checked?: boolean;
7
+ disabled?: boolean;
8
+ expanded?: boolean;
9
+ includeHidden?: boolean;
10
+ level?: number;
11
+ pressed?: boolean;
12
+ selected?: boolean;
13
+ };
14
+ export type PlaywrightTextOptions = {
15
+ exact?: boolean;
16
+ };
17
+ export type LocatorStrategyOptions<S extends string> = S extends RoleType ? PlaywrightRoleOptions : S extends 'text' | 'label' | 'title' | 'placeholder' | 'altText' ? PlaywrightTextOptions : {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pw-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "workspaces": [
5
5
  "examples",
6
6
  "create-pw-core"
@@ -23,6 +23,9 @@
23
23
  "typescript"
24
24
  ],
25
25
  "main": "./dist/index.js",
26
+ "bin": {
27
+ "pw-core": "./dist/cli.js"
28
+ },
26
29
  "types": "./dist/index.d.ts",
27
30
  "files": [
28
31
  "dist",
@@ -58,10 +61,14 @@
58
61
  "devDependencies": {
59
62
  "@playwright/test": "^1.61.0",
60
63
  "@types/node": "^20.11.0",
64
+ "prettier": "^3.9.4",
61
65
  "rimraf": "^6.0.1",
62
66
  "typescript": "^5.3.3"
63
67
  },
64
68
  "publishConfig": {
65
69
  "access": "public"
70
+ },
71
+ "dependencies": {
72
+ "playwright-core": "^1.61.1"
66
73
  }
67
74
  }