@qavajs/playwright-runner-adapter 2.3.3 → 2.5.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 (55) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +198 -11
  3. package/adapter/PlaywrightWorld.d.ts +8 -6
  4. package/adapter/PlaywrightWorld.js +21 -8
  5. package/adapter/PlaywrightWorld.js.map +1 -1
  6. package/adapter/Template.d.ts +13 -2
  7. package/adapter/Template.js +57 -8
  8. package/adapter/Template.js.map +1 -1
  9. package/adapter/cucumberAdapter.d.ts +7 -0
  10. package/adapter/cucumberAdapter.js +254 -114
  11. package/adapter/cucumberAdapter.js.map +1 -1
  12. package/adapter/filter.d.ts +8 -0
  13. package/adapter/filter.js +27 -1
  14. package/adapter/filter.js.map +1 -1
  15. package/adapter/gherkin.d.ts +45 -0
  16. package/adapter/gherkin.js +155 -0
  17. package/adapter/gherkin.js.map +1 -0
  18. package/adapter/index.d.ts +2 -0
  19. package/adapter/index.js +2 -0
  20. package/adapter/index.js.map +1 -1
  21. package/adapter/js/PlaywrightWorld.d.ts +8 -6
  22. package/adapter/js/PlaywrightWorld.js +21 -8
  23. package/adapter/js/Template.d.ts +13 -2
  24. package/adapter/js/Template.js +57 -8
  25. package/adapter/js/cucumberAdapter.d.ts +7 -0
  26. package/adapter/js/cucumberAdapter.js +254 -114
  27. package/adapter/js/filter.d.ts +8 -0
  28. package/adapter/js/filter.js +27 -1
  29. package/adapter/js/gherkin.d.ts +45 -0
  30. package/adapter/js/gherkin.js +154 -0
  31. package/adapter/js/index.d.ts +2 -0
  32. package/adapter/js/index.js +2 -0
  33. package/adapter/js/loader.d.ts +9 -1
  34. package/adapter/js/loader.js +35 -15
  35. package/adapter/js/testDetails.d.ts +28 -0
  36. package/adapter/js/testDetails.js +78 -0
  37. package/adapter/js/timeout.d.ts +17 -0
  38. package/adapter/js/timeout.js +24 -0
  39. package/adapter/js/types.d.ts +35 -6
  40. package/adapter/js/withWorld.d.ts +43 -0
  41. package/adapter/js/withWorld.js +16 -0
  42. package/adapter/loader.d.ts +9 -1
  43. package/adapter/loader.js +35 -15
  44. package/adapter/loader.js.map +1 -1
  45. package/adapter/testDetails.d.ts +28 -0
  46. package/adapter/testDetails.js +79 -0
  47. package/adapter/testDetails.js.map +1 -0
  48. package/adapter/timeout.d.ts +17 -0
  49. package/adapter/timeout.js +25 -0
  50. package/adapter/timeout.js.map +1 -0
  51. package/adapter/types.d.ts +35 -6
  52. package/adapter/withWorld.d.ts +43 -0
  53. package/adapter/withWorld.js +17 -0
  54. package/adapter/withWorld.js.map +1 -0
  55. package/package.json +11 -9
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AA8BA,oCAYC;AAED,kDASC;AAED,oBAQC;AA/DD,qCAAuC;AACvC,yCAAoC;AACpC,6CAAyC;AACzC,+CAA4F;AAC5F,iDAA+D;AAE/D,+BAAgC;AAChC,uDAAoD;AAGpD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,wBAAU,GAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,IAAI,oCAA0B,EAAE,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE3C,SAAS,UAAU,CAAC,KAAwB;IACxC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAA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umber/messages';
2
+ import type { TestDetailsAnnotation } from '@playwright/test';
3
+ export interface ResolvedTestDetails {
4
+ tag: string[];
5
+ annotation: TestDetailsAnnotation[];
6
+ lock: string[];
7
+ /** test timeout in milliseconds from `@timeout(ms)` tag (the last one wins) */
8
+ timeout?: number;
9
+ }
10
+ /**
11
+ * Resolve retries from `@retries(n)` feature tag.
12
+ * Playwright configures retries per describe block, so the tag is only supported on Feature.
13
+ */
14
+ export declare function resolveRetries(featureTags: readonly {
15
+ name: string;
16
+ }[]): number | undefined;
17
+ /**
18
+ * Translate gherkin tags of a pickle into playwright test details.
19
+ *
20
+ * - special tags below are consumed and not passed as playwright `tag`; all other tags are kept
21
+ * - `@lock(name)` → `lock: 'name'`; `@lock(-exclusive-)` → built-in exclusive lock
22
+ * - `@annotation(type,description)` → `annotation: { type, description }`
23
+ * - `@skip()` / `@fixme()` / `@fail()` / `@slow()` → playwright modifier with optional description, e.g. `@fixme(JIRA-1)`
24
+ * - `@timeout(ms)` → test timeout; `@retries(n)` → consumed here, applied per feature (see `resolveRetries`)
25
+ *
26
+ * Note: gherkin tags may not contain whitespace, so write `@annotation(issue,JIRA-1)` without spaces.
27
+ */
28
+ export declare function resolveTestDetails(pickle: Pickle): ResolvedTestDetails;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRetries = resolveRetries;
4
+ exports.resolveTestDetails = resolveTestDetails;
5
+ const LOCK_TAG = /^@lock\(([^)]+)\)$/;
6
+ const ANNOTATION_TAG = /^@annotation\(([^,)]+)(?:,(.*))?\)$/;
7
+ /**
8
+ * Playwright applies annotations of these types as test modifiers
9
+ * (skip/fixme before fixtures are set up, fail/slow at test start).
10
+ */
11
+ const MODIFIER_TAG = /^@(skip|fixme|fail|slow)\((.*)\)$/;
12
+ const TIMEOUT_TAG = /^@timeout\((\d+)\)$/;
13
+ const RETRIES_TAG = /^@retries\((\d+)\)$/;
14
+ /**
15
+ * Resolve retries from `@retries(n)` feature tag.
16
+ * Playwright configures retries per describe block, so the tag is only supported on Feature.
17
+ */
18
+ function resolveRetries(featureTags) {
19
+ let retries;
20
+ for (const { name } of featureTags) {
21
+ const match = RETRIES_TAG.exec(name);
22
+ if (match)
23
+ retries = Number(match[1]);
24
+ }
25
+ return retries;
26
+ }
27
+ function unique(items) {
28
+ return [...new Set(items)];
29
+ }
30
+ function createAnnotation(type, description) {
31
+ const trimmed = description?.trim();
32
+ return trimmed ? { type, description: trimmed } : { type };
33
+ }
34
+ /**
35
+ * Translate gherkin tags of a pickle into playwright test details.
36
+ *
37
+ * - special tags below are consumed and not passed as playwright `tag`; all other tags are kept
38
+ * - `@lock(name)` → `lock: 'name'`; `@lock(-exclusive-)` → built-in exclusive lock
39
+ * - `@annotation(type,description)` → `annotation: { type, description }`
40
+ * - `@skip()` / `@fixme()` / `@fail()` / `@slow()` → playwright modifier with optional description, e.g. `@fixme(JIRA-1)`
41
+ * - `@timeout(ms)` → test timeout; `@retries(n)` → consumed here, applied per feature (see `resolveRetries`)
42
+ *
43
+ * Note: gherkin tags may not contain whitespace, so write `@annotation(issue,JIRA-1)` without spaces.
44
+ */
45
+ function resolveTestDetails(pickle) {
46
+ const tag = [];
47
+ const extraAnnotation = [];
48
+ const lock = [];
49
+ let timeout;
50
+ for (const name of unique(pickle.tags.map(item => item.name))) {
51
+ const lockMatch = LOCK_TAG.exec(name);
52
+ if (lockMatch) {
53
+ lock.push(lockMatch[1].trim());
54
+ continue;
55
+ }
56
+ const timeoutMatch = TIMEOUT_TAG.exec(name);
57
+ if (timeoutMatch) {
58
+ timeout = Number(timeoutMatch[1]);
59
+ continue;
60
+ }
61
+ if (RETRIES_TAG.test(name)) {
62
+ continue;
63
+ }
64
+ const annotationMatch = ANNOTATION_TAG.exec(name) ?? MODIFIER_TAG.exec(name);
65
+ if (annotationMatch) {
66
+ extraAnnotation.push(createAnnotation(annotationMatch[1].trim(), annotationMatch[2]));
67
+ continue;
68
+ }
69
+ tag.push(name);
70
+ }
71
+ const annotation = [
72
+ { type: 'name', description: pickle.name },
73
+ { type: 'uri', description: pickle.uri },
74
+ { type: 'tags', description: JSON.stringify(tag) },
75
+ ...extraAnnotation
76
+ ];
77
+ return { tag, annotation, lock: unique(lock), ...(timeout === undefined ? {} : { timeout }) };
78
+ }
79
+ //# sourceMappingURL=testDetails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testDetails.js","sourceRoot":"","sources":["../src/testDetails.ts"],"names":[],"mappings":";;;;AAWA,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AACtC,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAC7D;;;GAGG;AACH,MAAM,YAAY,GAAG,mCAAmC,CAAC;AACzD,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAC1C,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C;;;GAGG;AACH,wBAA+B,WAAwC;IACnE,IAAI,OAA2B,CAAC;IAChC,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK;YAAE,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,MAAM,CAAI,KAAU;IACzB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,WAAoB;IACxD,MAAM,OAAO,GAAG,WAAW,EAAE,IAAI,EAAE,CAAC;IACpC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;GAUG;AACH,4BAAmC,MAAc;IAC7C,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AAE,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE;QACxC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAClD,GAAG,eAAe;KACrB,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAClG,CAAC"}
@@ -0,0 +1,17 @@
1
+ interface DefinitionWithTimeout {
2
+ options?: {
3
+ timeout?: number;
4
+ };
5
+ }
6
+ /**
7
+ * Resolve timeout of a step or hook definition:
8
+ * `{ timeout }` option of the definition, otherwise value set by `setDefaultTimeout`.
9
+ * Returns `undefined` when no timeout applies (not set, or disabled with `-1`/`0`);
10
+ * the Playwright test timeout still applies in that case.
11
+ */
12
+ export declare function resolveTimeout(definition: DefinitionWithTimeout, defaultTimeout?: number): number | undefined;
13
+ /**
14
+ * Run definition code, failing with `message` if it does not complete within `timeout` milliseconds
15
+ */
16
+ export declare function runWithTimeout<T>(code: () => T | Promise<T>, timeout: number | undefined, message: string): Promise<T>;
17
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveTimeout = resolveTimeout;
4
+ exports.runWithTimeout = runWithTimeout;
5
+ const cucumber_1 = require("@cucumber/cucumber");
6
+ /**
7
+ * Resolve timeout of a step or hook definition:
8
+ * `{ timeout }` option of the definition, otherwise value set by `setDefaultTimeout`.
9
+ * Returns `undefined` when no timeout applies (not set, or disabled with `-1`/`0`);
10
+ * the Playwright test timeout still applies in that case.
11
+ */
12
+ function resolveTimeout(definition, defaultTimeout) {
13
+ const timeout = definition.options?.timeout ?? defaultTimeout;
14
+ return timeout === undefined || timeout <= 0 ? undefined : timeout;
15
+ }
16
+ /**
17
+ * Run definition code, failing with `message` if it does not complete within `timeout` milliseconds
18
+ */
19
+ function runWithTimeout(code, timeout, message) {
20
+ const promise = Promise.resolve().then(code);
21
+ if (timeout === undefined)
22
+ return promise;
23
+ return (0, cucumber_1.wrapPromiseWithTimeout)(promise, timeout, message.replace('{timeout}', String(timeout)));
24
+ }
25
+ //# sourceMappingURL=timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../src/timeout.ts"],"names":[],"mappings":";;;;AAAA,iDAA4D;AAM5D;;;;;GAKG;AACH,wBAA+B,UAAiC,EAAE,cAAuB;IACrF,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC;IAC9D,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,wBAAkC,IAA0B,EAAE,OAA2B,EAAE,OAAe;IACtG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,IAAA,iCAAsB,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACnG,CAAC"}
@@ -1,18 +1,37 @@
1
1
  import type { GherkinDocument, Pickle } from '@cucumber/messages';
2
2
  import type { TestType } from '@playwright/test';
3
+ import type { Readable } from 'node:stream';
3
4
  export interface CucumberAdapterConfig {
5
+ /** Glob patterns for feature files. Can be overridden with `CUCUMBER_PATHS` env variable (comma separated). */
4
6
  paths: string[];
7
+ /** Glob patterns for step definition files */
5
8
  require?: string[];
9
+ /** Module names or paths (resolved from cwd) required before step definitions, e.g. `ts-node/register` */
6
10
  requireModules?: string[];
11
+ /** Glob patterns for step definition files */
7
12
  import?: string[];
13
+ /** Parameters available in world as `this.parameters` */
14
+ worldParameters?: unknown;
15
+ /** Cucumber tag expression to select scenarios. Combined with `CUCUMBER_TAGS` env variable using `and`. */
16
+ tags?: string;
17
+ /** Fail scenarios with pending steps (default `true`). When `false` such scenarios are marked as fixme. */
18
+ strict?: boolean;
19
+ /**
20
+ * Location reported for steps: `'definition'` (default) points to the step definition code,
21
+ * `'feature'` points to the step line in the feature file
22
+ */
23
+ stepLocation?: 'definition' | 'feature';
8
24
  [key: string]: unknown;
9
25
  }
26
+ export interface AttachOptions {
27
+ fileName?: string;
28
+ mediaType?: string;
29
+ }
30
+ export type AttachData = string | Buffer | Readable;
31
+ export type AttachFn = (data: AttachData, mediaTypeOrOptions?: string | AttachOptions) => Promise<void>;
10
32
  export interface WorldOptions {
11
33
  log?: (data: unknown) => void;
12
- attach?: (data: unknown, details?: {
13
- fileName?: string;
14
- mediaType?: string;
15
- }) => Promise<void>;
34
+ attach?: AttachFn;
16
35
  parameters?: unknown;
17
36
  supportCodeLibrary?: SupportCodeLibrary;
18
37
  config?: CucumberAdapterConfig;
@@ -21,13 +40,20 @@ export interface HookDefinition {
21
40
  uri?: string;
22
41
  line: number;
23
42
  name?: string;
24
- code: (this: unknown, ...args: unknown[]) => Promise<void> | void;
43
+ options?: {
44
+ timeout?: number;
45
+ };
46
+ code: (this: unknown, ...args: unknown[]) => unknown;
25
47
  appliesToTestCase(testCase: Pickle): boolean;
26
48
  }
27
49
  export interface StepDefinitionMatch {
28
50
  uri?: string;
29
51
  line: number;
30
- code: (this: unknown, ...args: unknown[]) => Promise<void> | void;
52
+ pattern?: string | RegExp;
53
+ options?: {
54
+ timeout?: number;
55
+ };
56
+ code: (this: unknown, ...args: unknown[]) => unknown;
31
57
  matchesStepName(text: string): boolean;
32
58
  getInvocationParameters(options: {
33
59
  step: {
@@ -52,6 +78,9 @@ export interface WorldBase {
52
78
  export interface SupportCodeLibrary {
53
79
  World: new (options: WorldOptions) => WorldBase;
54
80
  stepDefinitions: StepDefinitionMatch[];
81
+ parameterTypeRegistry: unknown;
82
+ /** set only when `setDefaultTimeout` is called */
83
+ defaultTimeout?: number;
55
84
  beforeTestRunHookDefinitions: HookDefinition[];
56
85
  afterTestRunHookDefinitions: HookDefinition[];
57
86
  beforeTestCaseHookDefinitions: HookDefinition[];
@@ -0,0 +1,43 @@
1
+ import { type ITestCaseHookParameter, type ITestStepHookParameter } from '@cucumber/cucumber';
2
+ type StepPattern = string | RegExp;
3
+ type StepFunction<World> = (this: World, ...args: any[]) => unknown;
4
+ type HookFunction<World, Parameter> = (this: World, parameter: Parameter) => unknown;
5
+ export interface StepOptions {
6
+ timeout?: number;
7
+ wrapperOptions?: unknown;
8
+ }
9
+ export interface HookOptions {
10
+ name?: string;
11
+ tags?: string;
12
+ timeout?: number;
13
+ }
14
+ export interface DefineStep<World> {
15
+ (pattern: StepPattern, code: StepFunction<World>): void;
16
+ (pattern: StepPattern, options: StepOptions, code: StepFunction<World>): void;
17
+ }
18
+ export interface DefineHook<World, Parameter> {
19
+ (code: HookFunction<World, Parameter>): void;
20
+ (tags: string, code: HookFunction<World, Parameter>): void;
21
+ (options: HookOptions, code: HookFunction<World, Parameter>): void;
22
+ }
23
+ export interface TypedSupportCode<World> {
24
+ Given: DefineStep<World>;
25
+ When: DefineStep<World>;
26
+ Then: DefineStep<World>;
27
+ defineStep: DefineStep<World>;
28
+ Before: DefineHook<World, ITestCaseHookParameter>;
29
+ After: DefineHook<World, ITestCaseHookParameter>;
30
+ BeforeStep: DefineHook<World, ITestStepHookParameter>;
31
+ AfterStep: DefineHook<World, ITestStepHookParameter>;
32
+ }
33
+ /**
34
+ * Get step and hook definition functions with `this` typed as the given world,
35
+ * so step definitions don't need `this: MyWorld` annotation
36
+ * @example
37
+ * const { Given, When, Before } = withWorld<MyWorld>();
38
+ * When('I open {string}', async function (url: string) {
39
+ * await this.page.goto(url); // `this` is MyWorld
40
+ * });
41
+ */
42
+ export declare function withWorld<World>(): TypedSupportCode<World>;
43
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withWorld = withWorld;
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ /**
6
+ * Get step and hook definition functions with `this` typed as the given world,
7
+ * so step definitions don't need `this: MyWorld` annotation
8
+ * @example
9
+ * const { Given, When, Before } = withWorld<MyWorld>();
10
+ * When('I open {string}', async function (url: string) {
11
+ * await this.page.goto(url); // `this` is MyWorld
12
+ * });
13
+ */
14
+ function withWorld() {
15
+ return { Given: cucumber_1.Given, When: cucumber_1.When, Then: cucumber_1.Then, defineStep: cucumber_1.defineStep, Before: cucumber_1.Before, After: cucumber_1.After, BeforeStep: cucumber_1.BeforeStep, AfterStep: cucumber_1.AfterStep };
16
+ }
17
+ //# sourceMappingURL=withWorld.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withWorld.js","sourceRoot":"","sources":["../src/withWorld.ts"],"names":[],"mappings":";;;AAAA,iDAW4B;AAuC5B;;;;;;;;GAQG;AACH;IACI,OAAO,EAAE,KAAK,EAAL,gBAAK,EAAE,IAAI,EAAJ,eAAI,EAAE,IAAI,EAAJ,eAAI,EAAE,UAAU,EAAV,qBAAU,EAAE,MAAM,EAAN,iBAAM,EAAE,KAAK,EAAL,gBAAK,EAAE,UAAU,EAAV,qBAAU,EAAE,SAAS,EAAT,oBAAS,EAAwC,CAAC;AACzH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/playwright-runner-adapter",
3
- "version": "2.3.3",
3
+ "version": "2.5.0",
4
4
  "description": "adapter for playwright test runner",
5
5
  "main": "adapter/index.js",
6
6
  "types": "adapter/index.d.ts",
@@ -28,7 +28,10 @@
28
28
  "scripts": {
29
29
  "build": "tsc && tsc --project tsconfig.js.json",
30
30
  "test:ui": "playwright test --config test/playwright.config.ts --ui",
31
- "test:e2e": "playwright test --config test/playwright.config.ts --project parallel --project serial --project unit"
31
+ "test:e2e": "playwright test --config test/playwright.config.ts --project parallel --project serial --project unit",
32
+ "test:all": "playwright test --config test/playwright.config.ts",
33
+ "test:types": "tsc -p test/tsconfig.json",
34
+ "test:package": "node test/package/run.mjs"
32
35
  },
33
36
  "author": "Alexandr Galichenko",
34
37
  "license": "MIT",
@@ -40,16 +43,15 @@
40
43
  "url": "https://github.com/qavajs/playwright-runner-adapter/issues"
41
44
  },
42
45
  "dependencies": {
43
- "@cucumber/cucumber": "^12.8.1",
44
- "@cucumber/gherkin": "^39.0.0",
45
- "@cucumber/tag-expressions": "^9.1.0",
46
- "glob": "^13.0.6"
46
+ "@cucumber/cucumber": "^13.3.0",
47
+ "@cucumber/gherkin": "^42.0.1",
48
+ "@cucumber/tag-expressions": "^11.0.1"
47
49
  },
48
50
  "devDependencies": {
49
- "@playwright/test": "^1.59.1",
51
+ "@playwright/test": "^1.65.0",
50
52
  "@qavajs/playwright-console-reporter": "^0.1.0",
51
- "@types/node": "^25.6.0",
52
- "typescript": "^6.0.3"
53
+ "@types/node": "^26.6.6",
54
+ "typescript": "^7.0.2"
53
55
  },
54
56
  "keywords": [
55
57
  "test",