@autometa/playwright-executor 1.0.0-rc.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.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @autometa/playwright-executor
2
+
3
+ Playwright executor for Autometa - provides runtime bindings that map Playwright's test primitives to Autometa's executor interface.
4
+
5
+ ## Overview
6
+
7
+ This package provides an `ExecutorRuntime` implementation for Playwright that allows Autometa to execute Gherkin feature files using Playwright's test runner.
8
+
9
+ ## Usage
10
+
11
+ This package is typically used internally by `@autometa/playwright-loader` but can be used directly:
12
+
13
+ ```typescript
14
+ import { execute } from '@autometa/playwright-executor';
15
+ import { coordinateRunnerFeature } from '@autometa/runner';
16
+ import { parseGherkin } from '@autometa/gherkin';
17
+
18
+ // Parse your feature file
19
+ const feature = parseGherkin(featureContent);
20
+
21
+ // Coordinate the runner
22
+ const { plan, adapter } = coordinateRunnerFeature({
23
+ feature,
24
+ environment: stepsEnvironment,
25
+ config: resolvedConfig
26
+ });
27
+
28
+ // Execute with Playwright runtime
29
+ execute({ plan, adapter, config: resolvedConfig });
30
+ ```
31
+
32
+ ## Runtime Mapping
33
+
34
+ The executor maps Autometa's execution primitives to Playwright's test API:
35
+
36
+ | Autometa | Playwright |
37
+ |-------------------|----------------------|
38
+ | `suite()` | `test.describe()` |
39
+ | `test()` | `test()` |
40
+ | `beforeAll()` | `test.beforeAll()` |
41
+ | `afterAll()` | `test.afterAll()` |
42
+ | `beforeEach()` | `test.beforeEach()` |
43
+ | `afterEach()` | `test.afterEach()` |
44
+
45
+ ## License
46
+
47
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var executor = require('@autometa/executor');
6
+ var test = require('@playwright/test');
7
+
8
+ // src/index.ts
9
+ function createPlaywrightRuntime() {
10
+ const baseSuite = function suite2(title, handler, _timeout) {
11
+ test.test.describe(title, handler);
12
+ };
13
+ const skipSuite = function skip(title, handler, _timeout) {
14
+ test.test.describe.skip(title, handler);
15
+ };
16
+ const onlySuite = function only(title, handler, _timeout) {
17
+ test.test.describe.only(title, handler);
18
+ };
19
+ const suite = Object.assign(baseSuite, {
20
+ skip: Object.assign(skipSuite, {
21
+ skip: skipSuite,
22
+ only: onlySuite
23
+ }),
24
+ only: Object.assign(onlySuite, {
25
+ skip: skipSuite,
26
+ only: onlySuite
27
+ })
28
+ });
29
+ const baseTest = function testFn2(title, handler, timeout) {
30
+ if (timeout) {
31
+ test.test(title, async () => {
32
+ test.test.setTimeout(timeout);
33
+ await handler();
34
+ });
35
+ } else {
36
+ test.test(title, handler);
37
+ }
38
+ };
39
+ const skipTest = function skip(title, handler, _timeout) {
40
+ test.test.skip(title, handler);
41
+ };
42
+ const onlyTest = function only(title, handler, timeout) {
43
+ if (timeout) {
44
+ test.test.only(title, async () => {
45
+ test.test.setTimeout(timeout);
46
+ await handler();
47
+ });
48
+ } else {
49
+ test.test.only(title, handler);
50
+ }
51
+ };
52
+ const todoTest = function todo(title, _reason) {
53
+ test.test.skip(title, () => void 0);
54
+ };
55
+ const testFn = Object.assign(baseTest, {
56
+ skip: Object.assign(skipTest, {
57
+ skip: skipTest,
58
+ only: onlyTest
59
+ }),
60
+ only: Object.assign(onlyTest, {
61
+ skip: skipTest,
62
+ only: onlyTest
63
+ }),
64
+ todo: todoTest
65
+ });
66
+ return {
67
+ suite,
68
+ test: testFn,
69
+ beforeAll: (handler, timeout) => {
70
+ test.test.beforeAll(async () => {
71
+ if (timeout) {
72
+ test.test.setTimeout(timeout);
73
+ }
74
+ await handler();
75
+ });
76
+ },
77
+ afterAll: (handler, timeout) => {
78
+ test.test.afterAll(async () => {
79
+ if (timeout) {
80
+ test.test.setTimeout(timeout);
81
+ }
82
+ await handler();
83
+ });
84
+ },
85
+ beforeEach: (handler, timeout) => {
86
+ test.test.beforeEach(async () => {
87
+ if (timeout) {
88
+ test.test.setTimeout(timeout);
89
+ }
90
+ await handler();
91
+ });
92
+ },
93
+ afterEach: (handler, timeout) => {
94
+ test.test.afterEach(async () => {
95
+ if (timeout) {
96
+ test.test.setTimeout(timeout);
97
+ }
98
+ await handler();
99
+ });
100
+ },
101
+ currentTestName: () => {
102
+ return void 0;
103
+ },
104
+ retry: (_count) => {
105
+ },
106
+ warn: (message) => {
107
+ console.warn(message);
108
+ },
109
+ logError: (error) => {
110
+ console.error(error);
111
+ }
112
+ };
113
+ }
114
+ var playwrightRuntime = createPlaywrightRuntime();
115
+ function execute(options) {
116
+ executor.registerFeaturePlan({
117
+ plan: options.plan,
118
+ adapter: options.adapter,
119
+ config: options.config,
120
+ runtime: playwrightRuntime
121
+ });
122
+ }
123
+ var src_default = { execute, playwrightRuntime };
124
+
125
+ Object.defineProperty(exports, 'expect', {
126
+ enumerable: true,
127
+ get: function () { return test.expect; }
128
+ });
129
+ Object.defineProperty(exports, 'test', {
130
+ enumerable: true,
131
+ get: function () { return test.test; }
132
+ });
133
+ exports.default = src_default;
134
+ exports.execute = execute;
135
+ exports.playwrightRuntime = playwrightRuntime;
136
+ //# sourceMappingURL=out.js.map
137
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["test","suite","testFn"],"mappings":";AAWA,SAAS,2BAA2B;AACpC,SAAS,YAAY;AAGrB,SAAS,QAAAA,OAAM,cAAc;AAU7B,SAAS,0BAA2C;AAElD,QAAM,YAAY,SAASC,OACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,OAAO,OAAO;AAAA,EAC9B;AAEA,QAAM,YAAY,SAAS,KACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,KAAK,OAAO,OAAO;AAAA,EACnC;AAEA,QAAM,YAAY,SAAS,KACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,KAAK,OAAO,OAAO;AAAA,EACnC;AAGA,QAAM,QAAQ,OAAO,OAAO,WAAW;AAAA,IACrC,MAAM,OAAO,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ACA,UAAU,CAAC,SAAS,YAAY;AAC9B,WAAK,SAAS,YAAY;AACxB,YAAI,SAAS;AACX,eAAK,WAAW,OAAO;AAAA,QACzB;AACA,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,IACA,YAAY,CAAC,SAAS,YAAY;AAChC,WAAK,WAAW,YAAY;AAC1B,YAAI,SAAS;AACX,eAAK,WAAW,OAAO;AAAA,QACzB;AACA,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,IACA,WAAW,CAAC,SAAS,YAAY;AAC/B,WAAK,UAAU,YAAY;AACzB,YAAI,SAAS;AACX,eAAK,WAAW,OAAO;AAAA,QACzB;AACA,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,IACA,iBAAiB,MAAM;AAGrB,aAAO;AAAA,IACT;AAAA,IACA,OAAO,CAAC,WAAmB;AAAA,IAG3B;AAAA,IACA,MAAM,CAAC,YAAoB;AACzB,cAAQ,KAAK,OAAO;AAAA,IACtB;AAAA,IACA,UAAU,CAAC,UAAiB;AAC1B,cAAQ,MAAM,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAKO,IAAM,oBAAqC,wBAAwB;AAgBnE,SAAS,QAAe,SAAsC;AACnE,sBAAoB;AAAA,IAClB,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,SAAS;AAAA,EACX,CAAC;AACH;AAEA,IAAO,cAAQ,EAAE,SAAS,kBAAkB","sourcesContent":["/**\n * Playwright Executor for Autometa\n *\n * Provides an ExecutorRuntime that maps Playwright's test primitives\n * to the common Autometa execution interface.\n */\n\nimport type { ExecutorConfig } from \"@autometa/config\";\nimport type { ScopeExecutionAdapter } from \"@autometa/scopes\";\nimport type { TestPlan } from \"@autometa/test-builder\";\nimport type { ExecutorRuntime, SuiteFn, TestFn } from \"@autometa/executor\";\nimport { registerFeaturePlan } from \"@autometa/executor\";\nimport { test } from \"@playwright/test\";\n\n// Re-export for convenience\nexport { test, expect } from \"@playwright/test\";\n\n/**\n * Create an ExecutorRuntime for Playwright.\n *\n * Playwright has a different structure than Vitest/Jest:\n * - test.describe() for suites\n * - test() for tests\n * - test.beforeAll(), test.afterAll(), test.beforeEach(), test.afterEach() for hooks\n */\nfunction createPlaywrightRuntime(): ExecutorRuntime {\n // Create suite function with skip/only variants\n const baseSuite = function suite(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe(title, handler);\n };\n\n const skipSuite = function skip(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe.skip(title, handler);\n };\n\n const onlySuite = function only(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe.only(title, handler);\n };\n\n // Build the suite object with circular references\n const suite = Object.assign(baseSuite, {\n skip: Object.assign(skipSuite, {\n skip: skipSuite as SuiteFn,\n only: onlySuite as SuiteFn,\n }),\n only: Object.assign(onlySuite, {\n skip: skipSuite as SuiteFn,\n only: onlySuite as SuiteFn,\n }),\n }) as SuiteFn;\n\n // Create test function with skip/only variants\n const baseTest = function testFn(\n title: string,\n handler: () => void | Promise<void>,\n timeout?: number\n ): void {\n if (timeout) {\n test(title, async () => {\n test.setTimeout(timeout);\n await handler();\n });\n } else {\n test(title, handler);\n }\n };\n\n const skipTest = function skip(\n title: string,\n handler: () => void | Promise<void>,\n _timeout?: number\n ): void {\n test.skip(title, handler);\n };\n\n const onlyTest = function only(\n title: string,\n handler: () => void | Promise<void>,\n timeout?: number\n ): void {\n if (timeout) {\n test.only(title, async () => {\n test.setTimeout(timeout);\n await handler();\n });\n } else {\n test.only(title, handler);\n }\n };\n\n const todoTest = function todo(title: string, _reason?: string): void {\n // Playwright doesn't have native todo, use skip\n test.skip(title, () => undefined);\n };\n\n // Build the test object with circular references\n const testFn = Object.assign(baseTest, {\n skip: Object.assign(skipTest, {\n skip: skipTest as TestFn,\n only: onlyTest as TestFn,\n }),\n only: Object.assign(onlyTest, {\n skip: skipTest as TestFn,\n only: onlyTest as TestFn,\n }),\n todo: todoTest,\n }) as TestFn;\n\n return {\n suite,\n test: testFn,\n beforeAll: (handler, timeout) => {\n test.beforeAll(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n afterAll: (handler, timeout) => {\n test.afterAll(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n beforeEach: (handler, timeout) => {\n test.beforeEach(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n afterEach: (handler, timeout) => {\n test.afterEach(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n currentTestName: () => {\n // Playwright doesn't expose current test name the same way\n // Return undefined for now\n return undefined;\n },\n retry: (_count: number) => {\n // Playwright handles retries at config level, not per-test\n // This is a no-op\n },\n warn: (message: string) => {\n console.warn(message);\n },\n logError: (error: Error) => {\n console.error(error);\n },\n };\n}\n\n/**\n * The default Playwright runtime instance.\n */\nexport const playwrightRuntime: ExecutorRuntime = createPlaywrightRuntime();\n\n/**\n * Options for executing a feature with Playwright.\n */\nexport interface ExecuteOptions<World> {\n readonly plan: TestPlan<World>;\n readonly adapter: ScopeExecutionAdapter<World>;\n readonly config: ExecutorConfig;\n}\n\n/**\n * Execute a feature test plan using Playwright.\n *\n * This is the main entry point for the generated bridge code.\n */\nexport function execute<World>(options: ExecuteOptions<World>): void {\n registerFeaturePlan({\n plan: options.plan,\n adapter: options.adapter,\n config: options.config,\n runtime: playwrightRuntime,\n });\n}\n\nexport default { execute, playwrightRuntime };\n"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Playwright Executor for Autometa
3
+ *
4
+ * Provides an ExecutorRuntime that maps Playwright's test primitives
5
+ * to the common Autometa execution interface.
6
+ */
7
+ import type { ExecutorConfig } from "@autometa/config";
8
+ import type { ScopeExecutionAdapter } from "@autometa/scopes";
9
+ import type { TestPlan } from "@autometa/test-builder";
10
+ import type { ExecutorRuntime } from "@autometa/executor";
11
+ export { test, expect } from "@playwright/test";
12
+ /**
13
+ * The default Playwright runtime instance.
14
+ */
15
+ export declare const playwrightRuntime: ExecutorRuntime;
16
+ /**
17
+ * Options for executing a feature with Playwright.
18
+ */
19
+ export interface ExecuteOptions<World> {
20
+ readonly plan: TestPlan<World>;
21
+ readonly adapter: ScopeExecutionAdapter<World>;
22
+ readonly config: ExecutorConfig;
23
+ }
24
+ /**
25
+ * Execute a feature test plan using Playwright.
26
+ *
27
+ * This is the main entry point for the generated bridge code.
28
+ */
29
+ export declare function execute<World>(options: ExecuteOptions<World>): void;
30
+ declare const _default: {
31
+ execute: typeof execute;
32
+ playwrightRuntime: ExecutorRuntime;
33
+ };
34
+ export default _default;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,oBAAoB,CAAC;AAK3E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA8JhD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,eAA2C,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAOnE;;;;;AAED,wBAA8C"}
package/dist/index.js ADDED
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Playwright Executor for Autometa
3
+ *
4
+ * Provides an ExecutorRuntime that maps Playwright's test primitives
5
+ * to the common Autometa execution interface.
6
+ */
7
+ import { registerFeaturePlan } from "@autometa/executor";
8
+ import { test } from "@playwright/test";
9
+ // Re-export for convenience
10
+ export { test, expect } from "@playwright/test";
11
+ /**
12
+ * Create an ExecutorRuntime for Playwright.
13
+ *
14
+ * Playwright has a different structure than Vitest/Jest:
15
+ * - test.describe() for suites
16
+ * - test() for tests
17
+ * - test.beforeAll(), test.afterAll(), test.beforeEach(), test.afterEach() for hooks
18
+ */
19
+ function createPlaywrightRuntime() {
20
+ // Create suite function with skip/only variants
21
+ const baseSuite = function suite(title, handler, _timeout) {
22
+ test.describe(title, handler);
23
+ };
24
+ const skipSuite = function skip(title, handler, _timeout) {
25
+ test.describe.skip(title, handler);
26
+ };
27
+ const onlySuite = function only(title, handler, _timeout) {
28
+ test.describe.only(title, handler);
29
+ };
30
+ // Build the suite object with circular references
31
+ const suite = Object.assign(baseSuite, {
32
+ skip: Object.assign(skipSuite, {
33
+ skip: skipSuite,
34
+ only: onlySuite,
35
+ }),
36
+ only: Object.assign(onlySuite, {
37
+ skip: skipSuite,
38
+ only: onlySuite,
39
+ }),
40
+ });
41
+ // Create test function with skip/only variants
42
+ const baseTest = function testFn(title, handler, timeout) {
43
+ if (timeout) {
44
+ test(title, async () => {
45
+ test.setTimeout(timeout);
46
+ await handler();
47
+ });
48
+ }
49
+ else {
50
+ test(title, handler);
51
+ }
52
+ };
53
+ const skipTest = function skip(title, handler, _timeout) {
54
+ test.skip(title, handler);
55
+ };
56
+ const onlyTest = function only(title, handler, timeout) {
57
+ if (timeout) {
58
+ test.only(title, async () => {
59
+ test.setTimeout(timeout);
60
+ await handler();
61
+ });
62
+ }
63
+ else {
64
+ test.only(title, handler);
65
+ }
66
+ };
67
+ const todoTest = function todo(title, _reason) {
68
+ // Playwright doesn't have native todo, use skip
69
+ test.skip(title, () => undefined);
70
+ };
71
+ // Build the test object with circular references
72
+ const testFn = Object.assign(baseTest, {
73
+ skip: Object.assign(skipTest, {
74
+ skip: skipTest,
75
+ only: onlyTest,
76
+ }),
77
+ only: Object.assign(onlyTest, {
78
+ skip: skipTest,
79
+ only: onlyTest,
80
+ }),
81
+ todo: todoTest,
82
+ });
83
+ return {
84
+ suite,
85
+ test: testFn,
86
+ beforeAll: (handler, timeout) => {
87
+ test.beforeAll(async () => {
88
+ if (timeout) {
89
+ test.setTimeout(timeout);
90
+ }
91
+ await handler();
92
+ });
93
+ },
94
+ afterAll: (handler, timeout) => {
95
+ test.afterAll(async () => {
96
+ if (timeout) {
97
+ test.setTimeout(timeout);
98
+ }
99
+ await handler();
100
+ });
101
+ },
102
+ beforeEach: (handler, timeout) => {
103
+ test.beforeEach(async () => {
104
+ if (timeout) {
105
+ test.setTimeout(timeout);
106
+ }
107
+ await handler();
108
+ });
109
+ },
110
+ afterEach: (handler, timeout) => {
111
+ test.afterEach(async () => {
112
+ if (timeout) {
113
+ test.setTimeout(timeout);
114
+ }
115
+ await handler();
116
+ });
117
+ },
118
+ currentTestName: () => {
119
+ // Playwright doesn't expose current test name the same way
120
+ // Return undefined for now
121
+ return undefined;
122
+ },
123
+ retry: (_count) => {
124
+ // Playwright handles retries at config level, not per-test
125
+ // This is a no-op
126
+ },
127
+ warn: (message) => {
128
+ console.warn(message);
129
+ },
130
+ logError: (error) => {
131
+ console.error(error);
132
+ },
133
+ };
134
+ }
135
+ /**
136
+ * The default Playwright runtime instance.
137
+ */
138
+ export const playwrightRuntime = createPlaywrightRuntime();
139
+ /**
140
+ * Execute a feature test plan using Playwright.
141
+ *
142
+ * This is the main entry point for the generated bridge code.
143
+ */
144
+ export function execute(options) {
145
+ registerFeaturePlan({
146
+ plan: options.plan,
147
+ adapter: options.adapter,
148
+ config: options.config,
149
+ runtime: playwrightRuntime,
150
+ });
151
+ }
152
+ export default { execute, playwrightRuntime };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["test","suite","testFn"],"mappings":";AAWA,SAAS,2BAA2B;AACpC,SAAS,YAAY;AAGrB,SAAS,QAAAA,OAAM,cAAc;AAU7B,SAAS,0BAA2C;AAElD,QAAM,YAAY,SAASC,OACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,OAAO,OAAO;AAAA,EAC9B;AAEA,QAAM,YAAY,SAAS,KACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,KAAK,OAAO,OAAO;AAAA,EACnC;AAEA,QAAM,YAAY,SAAS,KACzB,OACA,SACA,UACM;AACN,SAAK,SAAS,KAAK,OAAO,OAAO;AAAA,EACnC;AAGA,QAAM,QAAQ,OAAO,OAAO,WAAW;AAAA,IACrC,MAAM,OAAO,OAAO,WAAW;AAAA,MAC7B,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AAAA,IACD,MAAM,OAAO,OAAO,WAAW;AAAA,MAC7B,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AAAA,EACH,CAAC;AAGD,QAAM,WAAW,SAASC,QACxB,OACA,SACA,SACM;AACN,QAAI,SAAS;AACX,WAAK,OAAO,YAAY;AACtB,aAAK,WAAW,OAAO;AACvB,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACH,OAAO;AACL,WAAK,OAAO,OAAO;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,WAAW,SAAS,KACxB,OACA,SACA,UACM;AACN,SAAK,KAAK,OAAO,OAAO;AAAA,EAC1B;AAEA,QAAM,WAAW,SAAS,KACxB,OACA,SACA,SACM;AACN,QAAI,SAAS;AACX,WAAK,KAAK,OAAO,YAAY;AAC3B,aAAK,WAAW,OAAO;AACvB,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACH,OAAO;AACL,WAAK,KAAK,OAAO,OAAO;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM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rB;AAAA,EACF;AACF;AAKO,IAAM,oBAAqC,wBAAwB;AAgBnE,SAAS,QAAe,SAAsC;AACnE,sBAAoB;AAAA,IAClB,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,SAAS;AAAA,EACX,CAAC;AACH;AAEA,IAAO,cAAQ,EAAE,SAAS,kBAAkB","sourcesContent":["/**\n * Playwright Executor for Autometa\n *\n * Provides an ExecutorRuntime that maps Playwright's test primitives\n * to the common Autometa execution interface.\n */\n\nimport type { ExecutorConfig } from \"@autometa/config\";\nimport type { ScopeExecutionAdapter } from \"@autometa/scopes\";\nimport type { TestPlan } from \"@autometa/test-builder\";\nimport type { ExecutorRuntime, SuiteFn, TestFn } from \"@autometa/executor\";\nimport { registerFeaturePlan } from \"@autometa/executor\";\nimport { test } from \"@playwright/test\";\n\n// Re-export for convenience\nexport { test, expect } from \"@playwright/test\";\n\n/**\n * Create an ExecutorRuntime for Playwright.\n *\n * Playwright has a different structure than Vitest/Jest:\n * - test.describe() for suites\n * - test() for tests\n * - test.beforeAll(), test.afterAll(), test.beforeEach(), test.afterEach() for hooks\n */\nfunction createPlaywrightRuntime(): ExecutorRuntime {\n // Create suite function with skip/only variants\n const baseSuite = function suite(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe(title, handler);\n };\n\n const skipSuite = function skip(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe.skip(title, handler);\n };\n\n const onlySuite = function only(\n title: string,\n handler: () => void,\n _timeout?: number\n ): void {\n test.describe.only(title, handler);\n };\n\n // Build the suite object with circular references\n const suite = Object.assign(baseSuite, {\n skip: Object.assign(skipSuite, {\n skip: skipSuite as SuiteFn,\n only: onlySuite as SuiteFn,\n }),\n only: Object.assign(onlySuite, {\n skip: skipSuite as SuiteFn,\n only: onlySuite as SuiteFn,\n }),\n }) as SuiteFn;\n\n // Create test function with skip/only variants\n const baseTest = function testFn(\n title: string,\n handler: () => void | Promise<void>,\n timeout?: number\n ): void {\n if (timeout) {\n test(title, async () => {\n test.setTimeout(timeout);\n await handler();\n });\n } else {\n test(title, handler);\n }\n };\n\n const skipTest = function skip(\n title: string,\n handler: () => void | Promise<void>,\n _timeout?: number\n ): void {\n test.skip(title, handler);\n };\n\n const onlyTest = function only(\n title: string,\n handler: () => void | Promise<void>,\n timeout?: number\n ): void {\n if (timeout) {\n test.only(title, async () => {\n test.setTimeout(timeout);\n await handler();\n });\n } else {\n test.only(title, handler);\n }\n };\n\n const todoTest = function todo(title: string, _reason?: string): void {\n // Playwright doesn't have native todo, use skip\n test.skip(title, () => undefined);\n };\n\n // Build the test object with circular references\n const testFn = Object.assign(baseTest, {\n skip: Object.assign(skipTest, {\n skip: skipTest as TestFn,\n only: onlyTest as TestFn,\n }),\n only: Object.assign(onlyTest, {\n skip: skipTest as TestFn,\n only: onlyTest as TestFn,\n }),\n todo: todoTest,\n }) as TestFn;\n\n return {\n suite,\n test: testFn,\n beforeAll: (handler, timeout) => {\n test.beforeAll(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n afterAll: (handler, timeout) => {\n test.afterAll(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n beforeEach: (handler, timeout) => {\n test.beforeEach(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n afterEach: (handler, timeout) => {\n test.afterEach(async () => {\n if (timeout) {\n test.setTimeout(timeout);\n }\n await handler();\n });\n },\n currentTestName: () => {\n // Playwright doesn't expose current test name the same way\n // Return undefined for now\n return undefined;\n },\n retry: (_count: number) => {\n // Playwright handles retries at config level, not per-test\n // This is a no-op\n },\n warn: (message: string) => {\n console.warn(message);\n },\n logError: (error: Error) => {\n console.error(error);\n },\n };\n}\n\n/**\n * The default Playwright runtime instance.\n */\nexport const playwrightRuntime: ExecutorRuntime = createPlaywrightRuntime();\n\n/**\n * Options for executing a feature with Playwright.\n */\nexport interface ExecuteOptions<World> {\n readonly plan: TestPlan<World>;\n readonly adapter: ScopeExecutionAdapter<World>;\n readonly config: ExecutorConfig;\n}\n\n/**\n * Execute a feature test plan using Playwright.\n *\n * This is the main entry point for the generated bridge code.\n */\nexport function execute<World>(options: ExecuteOptions<World>): void {\n registerFeaturePlan({\n plan: options.plan,\n adapter: options.adapter,\n config: options.config,\n runtime: playwrightRuntime,\n });\n}\n\nexport default { execute, playwrightRuntime };\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@autometa/playwright-executor",
3
+ "version": "1.0.0-rc.0",
4
+ "description": "Playwright executor for Autometa - provides runtime bindings for Playwright",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs",
16
+ "default": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "@autometa/scopes": "1.0.0-rc.0",
23
+ "@autometa/test-builder": "1.0.0-rc.0",
24
+ "@autometa/executor": "1.0.0-rc.0",
25
+ "@autometa/config": "1.0.0-rc.0"
26
+ },
27
+ "devDependencies": {
28
+ "@playwright/test": "^1.40.0",
29
+ "@types/node": "^18.11.18",
30
+ "eslint": "^8.37.0",
31
+ "rimraf": "^4.1.2",
32
+ "tsup": "^7.2.0",
33
+ "typescript": "^4.9.5",
34
+ "vitest": "1.4.0",
35
+ "eslint-config-custom": "0.6.0",
36
+ "tsup-config": "0.1.0",
37
+ "tsconfig": "0.7.0"
38
+ },
39
+ "peerDependencies": {
40
+ "@playwright/test": "^1.40.0"
41
+ },
42
+ "scripts": {
43
+ "type-check": "tsc --noEmit -p tsconfig.dev.json",
44
+ "type-check:watch": "tsc --noEmit --watch -p tsconfig.dev.json",
45
+ "build": "tsup && pnpm run build:types",
46
+ "build:types": "rimraf tsconfig.types.tsbuildinfo && tsc --build tsconfig.types.json",
47
+ "build:watch": "tsup --watch",
48
+ "dev": "tsup --watch",
49
+ "test": "vitest run --passWithNoTests",
50
+ "test:watch": "vitest --passWithNoTests",
51
+ "test:ui": "vitest --ui --passWithNoTests",
52
+ "coverage": "vitest run --coverage --passWithNoTests",
53
+ "lint": "eslint . --max-warnings 0",
54
+ "lint:fix": "eslint . --fix",
55
+ "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
56
+ "clean": "rimraf dist"
57
+ }
58
+ }