@qavajs/playwright-runner-adapter 2.2.0 → 2.3.1
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/CHANGELOG.md +16 -0
- package/README.md +347 -39
- package/adapter/PlaywrightWorld.d.ts +9 -16
- package/adapter/PlaywrightWorld.js +12 -13
- package/adapter/PlaywrightWorld.js.map +1 -1
- package/adapter/cucumberAdapter.d.ts +2 -4
- package/adapter/cucumberAdapter.js +137 -186
- package/adapter/cucumberAdapter.js.map +1 -1
- package/adapter/js/PlaywrightWorld.d.ts +9 -16
- package/adapter/js/PlaywrightWorld.js +12 -13
- package/adapter/js/cucumberAdapter.d.ts +2 -4
- package/adapter/js/cucumberAdapter.js +137 -186
- package/adapter/js/loader.d.ts +4 -11
- package/adapter/js/types.d.ts +67 -0
- package/adapter/js/types.js +2 -0
- package/adapter/loader.d.ts +4 -11
- package/adapter/loader.js.map +1 -1
- package/adapter/types.d.ts +67 -0
- package/adapter/types.js +3 -0
- package/adapter/types.js.map +1 -0
- package/package.json +30 -9
- package/src/PlaywrightWorld.ts +0 -52
- package/src/Template.ts +0 -23
- package/src/cucumberAdapter.ts +0 -381
- package/src/filter.ts +0 -53
- package/src/index.ts +0 -5
- package/src/loader.ts +0 -70
- package/tsconfig.js.json +0 -23
- package/tsconfig.json +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,22 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
14
14
|
|
|
15
15
|
:microscope: - experimental
|
|
16
16
|
|
|
17
|
+
## [2.3.1]
|
|
18
|
+
- :beetle: fixed JUnit report path in PR workflow to use `test/report/report.xml`
|
|
19
|
+
- :pencil: added explicit `exports` map in `package.json` for root and `./js` entrypoints
|
|
20
|
+
- :pencil: restricted npm package contents via `files` allowlist in `package.json`
|
|
21
|
+
- :pencil: added shared type definitions (`CucumberAdapterConfig`, `HookDefinition`, `StepDefinitionMatch`, `SupportCodeLibrary`, `Feature`) replacing `any` throughout the codebase
|
|
22
|
+
- :pencil: added explicit `rootDir` to both `tsconfig.json` and `tsconfig.js.json` for forward compatibility with stricter TypeScript versions
|
|
23
|
+
- :beetle: improved error messages for undefined and ambiguous steps — now includes feature file URI and all matching step definition locations
|
|
24
|
+
- :rocket: added optional `DEBUG=cucumber-adapter` environment variable for step-matching trace logging
|
|
25
|
+
- :pencil: added tests for `{int}`, `{float}`, and `{word}` Cucumber parameter types
|
|
26
|
+
- :pencil: added tests for Scenario Outlines with multiple `Examples:` tables
|
|
27
|
+
- :pencil: added tests for tag-scoped `Before` and `After` hooks
|
|
28
|
+
- :pencil: added unit tests for `tags()` and `filter()` utility functions
|
|
29
|
+
|
|
30
|
+
## [2.3.0]
|
|
31
|
+
- :rocket: simplified adapter by moving hook into test
|
|
32
|
+
|
|
17
33
|
## [2.2.0]
|
|
18
34
|
- :rocket: added `request` into default fixture import
|
|
19
35
|
- :beetle: fixed `attach` method type
|
package/README.md
CHANGED
|
@@ -1,30 +1,56 @@
|
|
|
1
1
|
[](https://badge.fury.io/js/@qavajs%2Fplaywright-runner-adapter)
|
|
2
2
|
|
|
3
3
|
# @qavajs/playwright-runner-adapter
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
Adapter to run [Cucumber](https://cucumber.io/) BDD tests via the [Playwright](https://playwright.dev/) test runner. Write feature files in Gherkin, execute them with Playwright's parallelism, reporting, and fixture system.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Quick Start](#quick-start)
|
|
11
|
+
- [Configuration Reference](#configuration-reference)
|
|
12
|
+
- [World Classes](#world-classes)
|
|
13
|
+
- [TestWorld](#testworld)
|
|
14
|
+
- [PlaywrightWorld](#playwrightworld)
|
|
15
|
+
- [Custom World](#custom-world)
|
|
16
|
+
- [Hooks](#hooks)
|
|
17
|
+
- [Step Arguments](#step-arguments)
|
|
18
|
+
- [Template Steps](#template-steps)
|
|
19
|
+
- [Filtering Tests](#filtering-tests)
|
|
20
|
+
- [Tag Expressions](#tag-expressions)
|
|
21
|
+
- [Predicate Filter](#predicate-filter)
|
|
22
|
+
- [Parallelism](#parallelism)
|
|
23
|
+
- [JavaScript / CommonJS Support](#javascript--commonjs-support)
|
|
24
|
+
- [Limitations](#limitations)
|
|
25
|
+
|
|
26
|
+
---
|
|
5
27
|
|
|
6
28
|
## Installation
|
|
7
29
|
|
|
8
|
-
```
|
|
30
|
+
```bash
|
|
9
31
|
npm install @qavajs/playwright-runner-adapter
|
|
10
32
|
```
|
|
11
33
|
|
|
12
|
-
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
**1. Create a Cucumber config file**
|
|
13
39
|
|
|
14
|
-
### Create cucumber config file
|
|
15
|
-
Set `paths` and `require` properties
|
|
16
40
|
```typescript
|
|
17
41
|
// cucumber.config.ts
|
|
18
42
|
import { defineConfig } from '@qavajs/playwright-runner-adapter';
|
|
19
43
|
|
|
20
44
|
export default defineConfig({
|
|
21
|
-
paths: ['test/features
|
|
22
|
-
require: ['test/step_definitions
|
|
23
|
-
})
|
|
45
|
+
paths: ['test/features/**/*.feature'],
|
|
46
|
+
require: ['test/step_definitions/**/*.ts']
|
|
47
|
+
});
|
|
24
48
|
```
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
|
|
50
|
+
**2. Point Playwright at it**
|
|
51
|
+
|
|
27
52
|
```typescript
|
|
53
|
+
// playwright.config.ts
|
|
28
54
|
import { defineConfig } from '@playwright/test';
|
|
29
55
|
|
|
30
56
|
export default defineConfig({
|
|
@@ -32,13 +58,106 @@ export default defineConfig({
|
|
|
32
58
|
});
|
|
33
59
|
```
|
|
34
60
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
**3. Run tests**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx playwright test
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Configuration Reference
|
|
70
|
+
|
|
71
|
+
`defineConfig` accepts standard Cucumber options:
|
|
72
|
+
|
|
73
|
+
| Option | Type | Description |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `paths` | `string[]` | Glob patterns for `.feature` files |
|
|
76
|
+
| `require` | `string[]` | Glob patterns for step definition files (CommonJS `require`) |
|
|
77
|
+
| `import` | `string[]` | Glob patterns for step definition files (ESM `import`) |
|
|
78
|
+
| `requireModules` | `string[]` | Modules to require before step definitions (e.g. `ts-node/register`) |
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// cucumber.config.ts
|
|
82
|
+
import { defineConfig } from '@qavajs/playwright-runner-adapter';
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
paths: ['test/features/**/*.feature'],
|
|
86
|
+
require: ['test/step_definitions/**/*.ts'],
|
|
87
|
+
requireModules: [],
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## World Classes
|
|
94
|
+
|
|
95
|
+
### TestWorld
|
|
96
|
+
|
|
97
|
+
Base world class with Cucumber lifecycle methods and Playwright's `test` and `expect`.
|
|
98
|
+
|
|
39
99
|
```typescript
|
|
40
|
-
import {
|
|
41
|
-
|
|
100
|
+
import { TestWorld } from '@qavajs/playwright-runner-adapter';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Property | Type | Description |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `test` | `TestType` | Playwright `test` instance (default or custom) |
|
|
106
|
+
| `expect` | `ExpectType` | Playwright `expect` instance (default or custom) |
|
|
107
|
+
| `attach` | `function` | Attach files/data to the test report |
|
|
108
|
+
| `log` | `function` | Log data to console |
|
|
109
|
+
| `parameters` | `string` | Cucumber world parameters |
|
|
110
|
+
| `config` | `any` | Cucumber config object |
|
|
111
|
+
| `supportCodeLibrary` | `any` | Access to the loaded support code library |
|
|
112
|
+
|
|
113
|
+
**`executeStep(text, extraParam?)`** — programmatically invoke a step by its text:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
When('composite step', async function (this: PlaywrightWorld) {
|
|
117
|
+
await this.executeStep('I open the home page');
|
|
118
|
+
await this.executeStep('I click "Login"');
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### PlaywrightWorld
|
|
125
|
+
|
|
126
|
+
Extends `TestWorld` with Playwright browser fixtures pre-wired.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { PlaywrightWorld } from '@qavajs/playwright-runner-adapter';
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
| Property | Type | Description |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `page` | `Page` | Current Playwright page |
|
|
135
|
+
| `context` | `BrowserContext` | Current browser context |
|
|
136
|
+
| `browser` | `Browser` | Browser instance |
|
|
137
|
+
| `request` | `APIRequestContext` | API request context |
|
|
138
|
+
|
|
139
|
+
Use `PlaywrightWorld` (or a class extending it) as your world constructor when you need browser access in step definitions:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { setWorldConstructor, PlaywrightWorld } from '@qavajs/playwright-runner-adapter';
|
|
143
|
+
|
|
144
|
+
setWorldConstructor(PlaywrightWorld);
|
|
145
|
+
|
|
146
|
+
Given('I open {string}', async function (this: PlaywrightWorld, url: string) {
|
|
147
|
+
await this.page.goto(url);
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### Custom World
|
|
154
|
+
|
|
155
|
+
Extend `PlaywrightWorld` to add custom fixtures or override `test`/`expect`.
|
|
156
|
+
|
|
157
|
+
**Connecting custom Playwright fixtures:**
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { test as base, expect as baseExpect, Page } from '@playwright/test';
|
|
42
161
|
import { setWorldConstructor, PlaywrightWorld } from '@qavajs/playwright-runner-adapter';
|
|
43
162
|
|
|
44
163
|
type MyFixtures = {
|
|
@@ -52,51 +171,240 @@ const customTest = base.extend<MyFixtures>({
|
|
|
52
171
|
});
|
|
53
172
|
|
|
54
173
|
const customExpect = baseExpect.extend({
|
|
55
|
-
async
|
|
56
|
-
// implementation
|
|
57
|
-
}
|
|
174
|
+
async toBeValid(received) {
|
|
175
|
+
// custom matcher implementation
|
|
176
|
+
},
|
|
58
177
|
});
|
|
59
178
|
|
|
60
|
-
class
|
|
61
|
-
settingsPage
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// set test property with extened one
|
|
179
|
+
class MyWorld extends PlaywrightWorld {
|
|
180
|
+
settingsPage!: SettingsPage;
|
|
181
|
+
|
|
182
|
+
// Override test and expect with extended versions
|
|
67
183
|
test = customTest;
|
|
68
184
|
expect = customExpect;
|
|
69
|
-
|
|
70
|
-
// init
|
|
71
|
-
init = ({ settingsPage }) => {
|
|
185
|
+
|
|
186
|
+
// init is called with all fixtures — map them to world properties here
|
|
187
|
+
init = ({ page, settingsPage }: { page: Page; settingsPage: SettingsPage }) => {
|
|
188
|
+
this.page = page;
|
|
72
189
|
this.settingsPage = settingsPage;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
setWorldConstructor(MyWorld);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The `init` function receives Playwright fixtures as its argument. Its signature determines which fixtures Playwright injects — list only the fixtures you need.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Hooks
|
|
201
|
+
|
|
202
|
+
All standard Cucumber hooks are supported. Hooks run as named Playwright steps and appear in the trace viewer and HTML report.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import {
|
|
206
|
+
Before, After,
|
|
207
|
+
BeforeStep, AfterStep,
|
|
208
|
+
BeforeAll, AfterAll,
|
|
209
|
+
ITestCaseHookParameter,
|
|
210
|
+
ITestStepHookParameter,
|
|
211
|
+
} from '@qavajs/playwright-runner-adapter';
|
|
212
|
+
|
|
213
|
+
// Runs before each scenario
|
|
214
|
+
Before(async function (this: PlaywrightWorld, { pickle }: ITestCaseHookParameter) {
|
|
215
|
+
console.log('Starting:', pickle.name);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Runs after each scenario — result is available
|
|
219
|
+
After(async function (this: PlaywrightWorld, { result }: ITestCaseHookParameter) {
|
|
220
|
+
if (result?.status === 'FAILED') {
|
|
221
|
+
await this.page.screenshot({ path: 'failure.png' });
|
|
73
222
|
}
|
|
223
|
+
});
|
|
74
224
|
|
|
75
|
-
|
|
225
|
+
// Runs before/after each step
|
|
226
|
+
BeforeStep(async function (this: PlaywrightWorld, { pickleStep }: ITestStepHookParameter) {
|
|
227
|
+
console.log('Step:', pickleStep.text);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
AfterStep(async function (this: PlaywrightWorld, { result }: ITestStepHookParameter) {
|
|
231
|
+
console.log('Step status:', result?.status);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Runs once per worker process
|
|
235
|
+
BeforeAll(async function () {
|
|
236
|
+
// setup shared state
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
AfterAll(async function () {
|
|
240
|
+
// teardown shared state
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Named hooks** — supply a name to make the hook identifiable in reports:
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
Before({ name: 'Authenticate user' }, async function (this: PlaywrightWorld) {
|
|
248
|
+
// ...
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Scoped hooks** — use a tag expression to run hooks only for matching scenarios:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
Before({ tags: '@needsAuth' }, async function (this: PlaywrightWorld) {
|
|
256
|
+
// runs only for scenarios tagged @needsAuth
|
|
257
|
+
});
|
|
76
258
|
```
|
|
77
259
|
|
|
78
|
-
|
|
79
|
-
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Step Arguments
|
|
263
|
+
|
|
264
|
+
**Data Tables:**
|
|
265
|
+
|
|
266
|
+
```gherkin
|
|
267
|
+
When I submit the form
|
|
268
|
+
| field | value |
|
|
269
|
+
| username | alice |
|
|
270
|
+
| password | secret |
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { When, DataTable } from '@qavajs/playwright-runner-adapter';
|
|
275
|
+
|
|
276
|
+
When('I submit the form', async function (this: PlaywrightWorld, table: DataTable) {
|
|
277
|
+
const rows = table.hashes(); // [{ field: 'username', value: 'alice' }, ...]
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Doc Strings:**
|
|
282
|
+
|
|
283
|
+
```gherkin
|
|
284
|
+
When I set the body
|
|
285
|
+
"""
|
|
286
|
+
{"key": "value"}
|
|
287
|
+
"""
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
When('I set the body', async function (this: PlaywrightWorld, body: string) {
|
|
292
|
+
// body === '{"key": "value"}'
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Template Steps
|
|
299
|
+
|
|
300
|
+
`Template` composes a step out of other existing steps, eliminating the need for custom step implementations for common sequences.
|
|
80
301
|
|
|
81
302
|
```typescript
|
|
303
|
+
import { When, Template } from '@qavajs/playwright-runner-adapter';
|
|
304
|
+
|
|
305
|
+
When('I log in as {string}', Template((username: string) => `
|
|
306
|
+
I fill in "username" with "${username}"
|
|
307
|
+
I fill in "password" with "secret"
|
|
308
|
+
I click "Submit"
|
|
309
|
+
`));
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Each non-empty line in the returned string is executed as an individual step against the current world. Steps run sequentially; a failure stops the sequence.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Filtering Tests
|
|
317
|
+
|
|
318
|
+
### Tag Expressions
|
|
319
|
+
|
|
320
|
+
Use `tags` to translate a Cucumber tag expression into a Playwright `grep` pattern:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// playwright.config.ts
|
|
324
|
+
import { defineConfig } from '@playwright/test';
|
|
82
325
|
import { tags } from '@qavajs/playwright-runner-adapter';
|
|
326
|
+
|
|
83
327
|
export default defineConfig({
|
|
84
|
-
grep: tags('@
|
|
328
|
+
grep: tags('@smoke and not @slow'),
|
|
85
329
|
});
|
|
86
330
|
```
|
|
87
331
|
|
|
88
|
-
|
|
332
|
+
Supports the full [Cucumber tag expression syntax](https://github.com/cucumber/tag-expressions): `and`, `or`, `not`, parentheses.
|
|
333
|
+
|
|
334
|
+
### Predicate Filter
|
|
335
|
+
|
|
336
|
+
Use `filter` when you need arbitrary logic to select scenarios:
|
|
89
337
|
|
|
90
338
|
```typescript
|
|
339
|
+
import { defineConfig } from '@playwright/test';
|
|
91
340
|
import { filter } from '@qavajs/playwright-runner-adapter';
|
|
341
|
+
|
|
92
342
|
export default defineConfig({
|
|
93
|
-
grep: filter(name => name.includes('login
|
|
343
|
+
grep: filter(name => name.includes('login')),
|
|
94
344
|
});
|
|
95
345
|
```
|
|
96
346
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
347
|
+
The predicate receives the full test name (feature + scenario title + tags) and should return `true` to include the test.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Parallelism
|
|
352
|
+
|
|
353
|
+
Playwright projects let you run subsets of scenarios in parallel or serially:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// playwright.config.ts
|
|
357
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
358
|
+
import { tags } from '@qavajs/playwright-runner-adapter';
|
|
359
|
+
|
|
360
|
+
export default defineConfig({
|
|
361
|
+
testMatch: 'cucumber.config.ts',
|
|
362
|
+
projects: [
|
|
363
|
+
{
|
|
364
|
+
name: 'parallel',
|
|
365
|
+
grep: tags('not @serial'),
|
|
366
|
+
use: devices['Desktop Chrome'],
|
|
367
|
+
fullyParallel: true,
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: 'serial',
|
|
371
|
+
grep: tags('@serial'),
|
|
372
|
+
use: devices['Desktop Chrome'],
|
|
373
|
+
fullyParallel: false,
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
});
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Tag scenarios that must run serially with `@serial` (or any tag of your choice) and keep everything else fully parallel.
|
|
380
|
+
|
|
381
|
+
> To get the current worker index inside a step, use `this.test.info().parallelIndex`.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## JavaScript / CommonJS Support
|
|
386
|
+
|
|
387
|
+
If your step definitions are plain JavaScript (`.js`), import from the `./js` entrypoint to avoid TypeScript overhead:
|
|
388
|
+
|
|
389
|
+
```javascript
|
|
390
|
+
// cucumber.config.js
|
|
391
|
+
const { defineConfig } = require('@qavajs/playwright-runner-adapter/js');
|
|
392
|
+
|
|
393
|
+
module.exports = defineConfig({
|
|
394
|
+
paths: ['test/features/**/*.feature'],
|
|
395
|
+
require: ['test/step_definitions/**/*.js'],
|
|
396
|
+
});
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```javascript
|
|
400
|
+
// step_definitions/steps.js
|
|
401
|
+
const { Given, When, Then, PlaywrightWorld } = require('@qavajs/playwright-runner-adapter/js');
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
101
405
|
|
|
406
|
+
## Limitations
|
|
102
407
|
|
|
408
|
+
- **ES modules** — not supported for Node.js < 22 (where experimental ESM `require` is available). Use CommonJS or TypeScript with `ts-node`.
|
|
409
|
+
- **`setParallelCanAssign`** — not supported. Use Playwright [projects](https://playwright.dev/docs/test-projects) with `fullyParallel` to control parallelism.
|
|
410
|
+
- **`CUCUMBER_PARALLEL` / `CUCUMBER_TOTAL_WORKERS` / `CUCUMBER_WORKER_ID`** — not supported. Use `this.test.info().parallelIndex` and `this.test.info().workerIndex` instead.
|
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
import { APIRequestContext, Browser, BrowserContext, Page } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
* Cucumber world for playwright adapter
|
|
4
|
-
*/
|
|
2
|
+
import type { CucumberAdapterConfig, SupportCodeLibrary, WorldOptions } from './types';
|
|
5
3
|
export declare class TestWorld {
|
|
6
|
-
log: (data:
|
|
7
|
-
attach: (data:
|
|
4
|
+
log: (data: unknown) => void;
|
|
5
|
+
attach: (data: unknown, details?: {
|
|
8
6
|
fileName?: string;
|
|
9
7
|
mediaType: string;
|
|
10
8
|
}) => Promise<void>;
|
|
11
|
-
parameters:
|
|
12
|
-
config:
|
|
13
|
-
supportCodeLibrary:
|
|
9
|
+
parameters: unknown;
|
|
10
|
+
config: CucumberAdapterConfig;
|
|
11
|
+
supportCodeLibrary: SupportCodeLibrary;
|
|
14
12
|
test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
15
13
|
expect: import("@playwright/test").Expect<{}>;
|
|
16
|
-
constructor(options:
|
|
17
|
-
executeStep(this:
|
|
14
|
+
constructor(options: WorldOptions);
|
|
15
|
+
executeStep(this: TestWorld, text: string, extraParam?: unknown): Promise<void>;
|
|
18
16
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Cucumber Playwright world for playwright adapter
|
|
21
|
-
*/
|
|
22
17
|
export declare class PlaywrightWorld extends TestWorld {
|
|
23
18
|
page: Page;
|
|
24
19
|
context: BrowserContext;
|
|
25
20
|
browser: Browser;
|
|
26
21
|
browserName: string;
|
|
27
22
|
request: APIRequestContext;
|
|
28
|
-
init: (
|
|
29
|
-
[fixture: string]: any;
|
|
30
|
-
});
|
|
23
|
+
init: (fixtures: Record<string, unknown>) => void;
|
|
31
24
|
}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlaywrightWorld = exports.TestWorld = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
|
-
/**
|
|
6
|
-
* Cucumber world for playwright adapter
|
|
7
|
-
*/
|
|
8
5
|
class TestWorld {
|
|
9
6
|
log;
|
|
10
7
|
attach;
|
|
@@ -14,18 +11,22 @@ class TestWorld {
|
|
|
14
11
|
test = test_1.test;
|
|
15
12
|
expect = test_1.expect;
|
|
16
13
|
constructor(options) {
|
|
17
|
-
this.log = options.log;
|
|
14
|
+
this.log = options.log ?? console.log;
|
|
18
15
|
this.attach = options.attach;
|
|
19
16
|
this.parameters = options.parameters;
|
|
20
17
|
this.supportCodeLibrary = options.supportCodeLibrary;
|
|
18
|
+
this.config = options.config;
|
|
21
19
|
}
|
|
22
20
|
async executeStep(text, extraParam) {
|
|
23
|
-
const steps = this.supportCodeLibrary.stepDefinitions
|
|
21
|
+
const steps = this.supportCodeLibrary.stepDefinitions
|
|
22
|
+
.filter(s => s.matchesStepName(text));
|
|
24
23
|
if (steps.length === 0)
|
|
25
24
|
throw new Error(`Step "${text}" is not defined`);
|
|
26
|
-
if (steps.length > 1)
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (steps.length > 1) {
|
|
26
|
+
const locations = steps.map(s => ` ${s.uri}:${s.line}`).join('\n');
|
|
27
|
+
throw new Error(`Step "${text}" matches multiple step definitions:\n${locations}`);
|
|
28
|
+
}
|
|
29
|
+
const step = steps[0];
|
|
29
30
|
const { parameters } = await step.getInvocationParameters({ step: { text }, world: this });
|
|
30
31
|
try {
|
|
31
32
|
await step.code.apply(this, [...parameters, extraParam]);
|
|
@@ -36,21 +37,19 @@ class TestWorld {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
exports.TestWorld = TestWorld;
|
|
39
|
-
/**
|
|
40
|
-
* Cucumber Playwright world for playwright adapter
|
|
41
|
-
*/
|
|
42
40
|
class PlaywrightWorld extends TestWorld {
|
|
43
41
|
page;
|
|
44
42
|
context;
|
|
45
43
|
browser;
|
|
46
44
|
browserName;
|
|
47
45
|
request;
|
|
48
|
-
|
|
46
|
+
// Cast preserves the destructured param form that Playwright reads via toString() to discover fixtures
|
|
47
|
+
init = (({ browser, context, page, request }) => {
|
|
49
48
|
this.browser = browser;
|
|
50
49
|
this.context = context;
|
|
51
50
|
this.page = page;
|
|
52
51
|
this.request = request;
|
|
53
|
-
};
|
|
52
|
+
});
|
|
54
53
|
}
|
|
55
54
|
exports.PlaywrightWorld = PlaywrightWorld;
|
|
56
55
|
//# sourceMappingURL=PlaywrightWorld.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightWorld.js","sourceRoot":"","sources":["../src/PlaywrightWorld.ts"],"names":[],"mappings":";;;AAAA,2CAAkG;
|
|
1
|
+
{"version":3,"file":"PlaywrightWorld.js","sourceRoot":"","sources":["../src/PlaywrightWorld.ts"],"names":[],"mappings":";;;AAAA,2CAAkG;AAGlG,MAAa,SAAS;IAClB,GAAG,CAA2B;IAC9B,MAAM,CAAwF;IAC9F,UAAU,CAAW;IACrB,MAAM,CAAyB;IAC/B,kBAAkB,CAAsB;IACxC,IAAI,GAAG,WAAI,CAAC;IACZ,MAAM,GAAG,aAAM,CAAC;IAEhB,YAAY,OAAqB;QAC7B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAA6B,CAAC;QACpD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAmB,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAO,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,WAAW,CAAkB,IAAY,EAAE,UAAoB;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,eAAe;aAChD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,kBAAkB,CAAC,CAAC;QACzE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,yCAAyC,SAAS,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3F,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;CACJ;AAjCD,8BAiCC;AAED,MAAa,eAAgB,SAAQ,SAAS;IAC1C,IAAI,CAAQ;IACZ,OAAO,CAAkB;IACzB,OAAO,CAAW;IAClB,WAAW,CAAU;IACrB,OAAO,CAAqB;IAE5B,uGAAuG;IACvG,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAyF,EAAE,EAAE;QACnI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC,CAAgD,CAAC;CACrD;AAdD,0CAcC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export declare function defineConfig(config: any): any;
|
|
1
|
+
import type { CucumberAdapterConfig } from './types';
|
|
2
|
+
export declare function defineConfig(config: CucumberAdapterConfig): void;
|