@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
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineConfig = defineConfig;
|
|
4
4
|
const loader_1 = require("./loader");
|
|
5
|
-
|
|
5
|
+
const DEBUG = process.env.DEBUG?.split(',').includes('cucumber-adapter') ?? false;
|
|
6
6
|
const ANNOTATION_TYPES = {
|
|
7
|
-
TEST_ID: '_testId',
|
|
8
7
|
NAME: 'name',
|
|
9
8
|
URI: 'uri',
|
|
10
9
|
TAGS: 'tags'
|
|
@@ -31,34 +30,6 @@ const STEP_ARGUMENT_LABELS = {
|
|
|
31
30
|
DOC_STRING: ' [MultiLine]',
|
|
32
31
|
DATA_TABLE: ' [DataTable]'
|
|
33
32
|
};
|
|
34
|
-
/**
|
|
35
|
-
* Extracts the test ID from TestInfo annotations
|
|
36
|
-
*/
|
|
37
|
-
function getTestId(testInfo) {
|
|
38
|
-
const annotation = testInfo.annotations
|
|
39
|
-
.find((annotation) => annotation.type === ANNOTATION_TYPES.TEST_ID);
|
|
40
|
-
if (!annotation?.description) {
|
|
41
|
-
throw new Error('Test ID annotation not found');
|
|
42
|
-
}
|
|
43
|
-
return annotation.description;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Converts TestInfo to HookResult format
|
|
47
|
-
*/
|
|
48
|
-
function getResult(testInfo) {
|
|
49
|
-
const message = testInfo.errors.length > 0
|
|
50
|
-
? testInfo.errors.map((err) => err.message).join('\n')
|
|
51
|
-
: undefined;
|
|
52
|
-
return {
|
|
53
|
-
duration: testInfo.duration,
|
|
54
|
-
message,
|
|
55
|
-
status: testInfo.status?.toUpperCase() ?? 'UNKNOWN',
|
|
56
|
-
exception: testInfo.error
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates a location object from step definition
|
|
61
|
-
*/
|
|
62
33
|
function getLine(step) {
|
|
63
34
|
return {
|
|
64
35
|
location: {
|
|
@@ -68,23 +39,14 @@ function getLine(step) {
|
|
|
68
39
|
}
|
|
69
40
|
};
|
|
70
41
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Logs data to console
|
|
73
|
-
*/
|
|
74
42
|
function log(data) {
|
|
75
43
|
console.log(data);
|
|
76
44
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Attaches content to test report
|
|
79
|
-
*/
|
|
80
45
|
function attach(body, details) {
|
|
81
46
|
const fileName = details?.fileName ?? DEFAULT_VALUES.ATTACHMENT_FILENAME;
|
|
82
47
|
const contentType = details?.mediaType ?? DEFAULT_VALUES.CONTENT_TYPE;
|
|
83
|
-
return this.test.info().attach(fileName, { body, contentType });
|
|
48
|
+
return this.test.info().attach(fileName, { body: body, contentType });
|
|
84
49
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Generates a human-readable step name with argument type indicator
|
|
87
|
-
*/
|
|
88
50
|
function stepName(pickleStep) {
|
|
89
51
|
let step = pickleStep.text;
|
|
90
52
|
if (pickleStep.argument) {
|
|
@@ -94,9 +56,91 @@ function stepName(pickleStep) {
|
|
|
94
56
|
}
|
|
95
57
|
return step;
|
|
96
58
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
59
|
+
function createTestExecutionResult() {
|
|
60
|
+
return {
|
|
61
|
+
status: 'passed',
|
|
62
|
+
start: Date.now()
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function createHookResult(result) {
|
|
66
|
+
return {
|
|
67
|
+
duration: Date.now() - result.start,
|
|
68
|
+
message: result.error?.message,
|
|
69
|
+
status: result.status.toUpperCase(),
|
|
70
|
+
exception: result.error
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function createScenarioAnnotation(testCase) {
|
|
74
|
+
const tag = [...new Set(testCase.tags.map(item => item.name))];
|
|
75
|
+
return [
|
|
76
|
+
{ type: ANNOTATION_TYPES.NAME, description: testCase.name },
|
|
77
|
+
{ type: ANNOTATION_TYPES.URI, description: testCase.uri },
|
|
78
|
+
{ type: ANNOTATION_TYPES.TAGS, description: JSON.stringify(tag) }
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
function createScenarioTags(testCase) {
|
|
82
|
+
return [...new Set(testCase.tags.map(item => item.name))];
|
|
83
|
+
}
|
|
84
|
+
function createCaseHookPayload(feature, testCase) {
|
|
85
|
+
return {
|
|
86
|
+
gherkinDocument: feature.gherkinDocument,
|
|
87
|
+
pickle: testCase
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function executeCaseHooks(test, hooks, world, testCase, defaultHookName, createPayload) {
|
|
91
|
+
for (const hook of hooks) {
|
|
92
|
+
if (!hook.appliesToTestCase(testCase)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const hookName = hook.name ?? defaultHookName;
|
|
96
|
+
const location = getLine(hook);
|
|
97
|
+
await test.step(hookName, () => hook.code.apply(world, [createPayload(hook)]), location);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function executeStepHooks(test, hooks, world, testCase, hookName, createPayload) {
|
|
101
|
+
for (const hook of hooks) {
|
|
102
|
+
if (!hook.appliesToTestCase(testCase)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const location = getLine(hook);
|
|
106
|
+
await test.step(hookName, () => hook.code.apply(world, [createPayload(hook)]), location);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function createStepHookParameter(feature, testCase, pickleStep, result) {
|
|
110
|
+
return {
|
|
111
|
+
gherkinDocument: feature.gherkinDocument,
|
|
112
|
+
testCaseStartedId: DEFAULT_VALUES.TEST_CASE_ID,
|
|
113
|
+
testStepId: DEFAULT_VALUES.TEST_STEP_ID,
|
|
114
|
+
pickle: testCase,
|
|
115
|
+
pickleStep,
|
|
116
|
+
result: createHookResult(result)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function createCaseHookParameter(feature, testCase, result) {
|
|
120
|
+
return {
|
|
121
|
+
gherkinDocument: feature.gherkinDocument,
|
|
122
|
+
testCaseStartedId: DEFAULT_VALUES.TEST_CASE_ID,
|
|
123
|
+
pickle: testCase,
|
|
124
|
+
result: createHookResult(result)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function findSingleStepDefinition(supportCodeLibrary, pickleStep, featureUri) {
|
|
128
|
+
const matchingSteps = supportCodeLibrary.stepDefinitions
|
|
129
|
+
.filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
|
|
130
|
+
if (DEBUG) {
|
|
131
|
+
console.log(`[cucumber-adapter] Matching: "${pickleStep.text}" — ${matchingSteps.length} match(es)`);
|
|
132
|
+
}
|
|
133
|
+
if (matchingSteps.length === 0) {
|
|
134
|
+
throw new Error(`Step '${pickleStep.text}' is not defined\n at ${featureUri}`);
|
|
135
|
+
}
|
|
136
|
+
if (matchingSteps.length > 1) {
|
|
137
|
+
const locations = matchingSteps
|
|
138
|
+
.map(s => ` ${s.uri}:${s.line}`)
|
|
139
|
+
.join('\n');
|
|
140
|
+
throw new Error(`Step '${pickleStep.text}' matches multiple step definitions:\n${locations}`);
|
|
141
|
+
}
|
|
142
|
+
return matchingSteps[0];
|
|
143
|
+
}
|
|
100
144
|
function executeBeforeAllHooks(test, hooks) {
|
|
101
145
|
if (hooks.length === 0)
|
|
102
146
|
return;
|
|
@@ -107,9 +151,6 @@ function executeBeforeAllHooks(test, hooks) {
|
|
|
107
151
|
}
|
|
108
152
|
});
|
|
109
153
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Executes after all hooks
|
|
112
|
-
*/
|
|
113
154
|
function executeAfterAllHooks(test, hooks) {
|
|
114
155
|
if (hooks.length === 0)
|
|
115
156
|
return;
|
|
@@ -120,158 +161,68 @@ function executeAfterAllHooks(test, hooks) {
|
|
|
120
161
|
}
|
|
121
162
|
});
|
|
122
163
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates test annotations from test case data
|
|
125
|
-
*/
|
|
126
|
-
function createTestAnnotations(testCase) {
|
|
127
|
-
const tags = [...new Set(testCase.tags.map((tag) => tag.name))];
|
|
128
|
-
return [
|
|
129
|
-
{ type: ANNOTATION_TYPES.NAME, description: testCase.name },
|
|
130
|
-
{ type: ANNOTATION_TYPES.URI, description: testCase.uri },
|
|
131
|
-
{ type: ANNOTATION_TYPES.TAGS, description: JSON.stringify(tags) },
|
|
132
|
-
{ type: ANNOTATION_TYPES.TEST_ID, description: testCase.id }
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Main configuration function that sets up Cucumber adapter for Playwright
|
|
137
|
-
*/
|
|
138
164
|
function defineConfig(config) {
|
|
139
165
|
const { features, supportCodeLibrary } = (0, loader_1.load)(config);
|
|
140
166
|
const fixture = new supportCodeLibrary.World({ config });
|
|
141
167
|
const test = fixture.test;
|
|
142
168
|
executeBeforeAllHooks(test, supportCodeLibrary.beforeTestRunHookDefinitions);
|
|
143
|
-
const worlds = new Map();
|
|
144
169
|
for (const feature of features) {
|
|
145
170
|
const tests = feature.tests;
|
|
146
|
-
test.describe(feature.feature,
|
|
147
|
-
/**
|
|
148
|
-
* Factory function to create and register world instances
|
|
149
|
-
*/
|
|
150
|
-
const worldFactory = (fixtures) => {
|
|
151
|
-
const world = new supportCodeLibrary.World({
|
|
152
|
-
log,
|
|
153
|
-
attach,
|
|
154
|
-
supportCodeLibrary,
|
|
155
|
-
config
|
|
156
|
-
});
|
|
157
|
-
world.init(fixtures);
|
|
158
|
-
worlds.set(getTestId(test.info()), world);
|
|
159
|
-
};
|
|
160
|
-
worldFactory.toString = () => fixture.init.toString();
|
|
161
|
-
test.beforeEach(HOOK_NAMES.WORLD, worldFactory);
|
|
162
|
-
test.beforeEach(HOOK_NAMES.BEFORE_HOOKS, async () => {
|
|
163
|
-
const testId = getTestId(test.info());
|
|
164
|
-
const world = worlds.get(testId);
|
|
165
|
-
const testCase = tests.find((t) => t.id === testId);
|
|
166
|
-
if (!testCase) {
|
|
167
|
-
throw new Error(`Test case with ID ${testId} not found`);
|
|
168
|
-
}
|
|
169
|
-
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
170
|
-
if (beforeHook.appliesToTestCase(testCase)) {
|
|
171
|
-
const hookName = beforeHook.name ?? HOOK_NAMES.BEFORE;
|
|
172
|
-
const location = getLine(beforeHook);
|
|
173
|
-
await test.step(hookName, () => beforeHook.code.apply(world, [{
|
|
174
|
-
gherkinDocument: feature.gherkinDocument,
|
|
175
|
-
pickle: testCase
|
|
176
|
-
}]), location);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
171
|
+
test.describe(feature.feature, () => {
|
|
180
172
|
for (const testCase of tests) {
|
|
181
|
-
const tag =
|
|
182
|
-
const annotation =
|
|
183
|
-
|
|
184
|
-
const world =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
const [step] = matchingSteps;
|
|
199
|
-
const location = getLine(step);
|
|
200
|
-
await test.step(stepName(pickleStep), async () => {
|
|
201
|
-
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
202
|
-
if (beforeStep.appliesToTestCase(testCase)) {
|
|
203
|
-
const location = getLine(beforeStep);
|
|
204
|
-
await test.step(HOOK_NAMES.BEFORE_STEP, () => beforeStep.code.apply(world, [{
|
|
205
|
-
gherkinDocument: feature.gherkinDocument,
|
|
206
|
-
pickle: testCase,
|
|
207
|
-
pickleStep
|
|
208
|
-
}]), location);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
const { parameters } = await step.getInvocationParameters({
|
|
212
|
-
step: {
|
|
213
|
-
text: pickleStep.text,
|
|
214
|
-
argument: pickleStep.argument
|
|
215
|
-
},
|
|
216
|
-
world
|
|
217
|
-
});
|
|
218
|
-
try {
|
|
219
|
-
await step.code.apply(world, parameters);
|
|
220
|
-
}
|
|
221
|
-
catch (err) {
|
|
222
|
-
result.status = 'failed';
|
|
223
|
-
result.error = err;
|
|
224
|
-
throw err;
|
|
173
|
+
const tag = createScenarioTags(testCase);
|
|
174
|
+
const annotation = createScenarioAnnotation(testCase);
|
|
175
|
+
const testBody = async (fixtures) => {
|
|
176
|
+
const world = new supportCodeLibrary.World({
|
|
177
|
+
log,
|
|
178
|
+
attach,
|
|
179
|
+
supportCodeLibrary,
|
|
180
|
+
config
|
|
181
|
+
});
|
|
182
|
+
world.init(fixtures);
|
|
183
|
+
const result = createTestExecutionResult();
|
|
184
|
+
await executeCaseHooks(test, supportCodeLibrary.beforeTestCaseHookDefinitions, world, testCase, HOOK_NAMES.BEFORE, () => createCaseHookPayload(feature, testCase));
|
|
185
|
+
try {
|
|
186
|
+
for (const pickleStep of testCase.steps) {
|
|
187
|
+
if (result.status !== 'passed') {
|
|
188
|
+
break;
|
|
225
189
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
190
|
+
const step = findSingleStepDefinition(supportCodeLibrary, pickleStep, feature.uri);
|
|
191
|
+
const location = getLine(step);
|
|
192
|
+
await test.step(stepName(pickleStep), async () => {
|
|
193
|
+
await executeStepHooks(test, supportCodeLibrary.beforeTestStepHookDefinitions, world, testCase, HOOK_NAMES.BEFORE_STEP, () => ({
|
|
194
|
+
gherkinDocument: feature.gherkinDocument,
|
|
195
|
+
pickle: testCase,
|
|
196
|
+
pickleStep
|
|
197
|
+
}));
|
|
198
|
+
const { parameters } = await step.getInvocationParameters({
|
|
199
|
+
step: {
|
|
200
|
+
text: pickleStep.text,
|
|
201
|
+
argument: pickleStep.argument
|
|
202
|
+
},
|
|
203
|
+
world
|
|
204
|
+
});
|
|
205
|
+
try {
|
|
206
|
+
await step.code.apply(world, parameters);
|
|
244
207
|
}
|
|
245
|
-
|
|
246
|
-
|
|
208
|
+
catch (err) {
|
|
209
|
+
result.status = 'failed';
|
|
210
|
+
result.error = err;
|
|
211
|
+
throw err;
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
await executeStepHooks(test, supportCodeLibrary.afterTestStepHookDefinitions, world, testCase, HOOK_NAMES.AFTER_STEP, () => createStepHookParameter(feature, testCase, pickleStep, result));
|
|
215
|
+
}
|
|
216
|
+
}, location);
|
|
217
|
+
}
|
|
247
218
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
test.afterEach(HOOK_NAMES.AFTER_HOOKS, async () => {
|
|
251
|
-
const testInfo = test.info();
|
|
252
|
-
const testId = getTestId(testInfo);
|
|
253
|
-
const world = worlds.get(testId);
|
|
254
|
-
const testCase = tests.find((t) => t.id === testId);
|
|
255
|
-
if (!testCase) {
|
|
256
|
-
throw new Error(`Test case with ID ${testId} not found`);
|
|
257
|
-
}
|
|
258
|
-
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
259
|
-
if (afterHook.appliesToTestCase(testCase)) {
|
|
260
|
-
const hookName = afterHook.name ?? HOOK_NAMES.AFTER;
|
|
261
|
-
const location = getLine(afterHook);
|
|
262
|
-
await test.step(hookName, () => afterHook.code.apply(world, [{
|
|
263
|
-
gherkinDocument: feature.gherkinDocument,
|
|
264
|
-
testCaseStartedId: DEFAULT_VALUES.TEST_CASE_ID,
|
|
265
|
-
pickle: testCase,
|
|
266
|
-
result: getResult(testInfo)
|
|
267
|
-
}]), location);
|
|
219
|
+
finally {
|
|
220
|
+
await executeCaseHooks(test, supportCodeLibrary.afterTestCaseHookDefinitions, world, testCase, HOOK_NAMES.AFTER, () => createCaseHookParameter(feature, testCase, result));
|
|
268
221
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
worlds.delete(testId);
|
|
274
|
-
});
|
|
222
|
+
};
|
|
223
|
+
testBody.toString = () => fixture.init.toString();
|
|
224
|
+
test(testCase.name, { tag, annotation }, testBody);
|
|
225
|
+
}
|
|
275
226
|
});
|
|
276
227
|
}
|
|
277
228
|
executeAfterAllHooks(test, supportCodeLibrary.afterTestRunHookDefinitions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cucumberAdapter.js","sourceRoot":"","sources":["../src/cucumberAdapter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cucumberAdapter.js","sourceRoot":"","sources":["../src/cucumberAdapter.ts"],"names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ACJ,kBAAkB,CAAC,4BAA4B,EAC/C,KAAK,EACL,QAAQ,EACR,UAAU,CAAC,UAAU,EACrB,GAAG,EAAE,CAAC,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CACvE,CAAC;gCACN,CAAC;4BACL,CAAC,EAAE,QAAQ,CAAC,CAAC;wBACjB,CAAC;oBACL,CAAC;4BAAS,CAAC;wBACP,MAAM,gBAAgB,CAClB,IAAI,EACJ,kBAAkB,CAAC,4BAA4B,EAC/C,KAAK,EACL,QAAQ,EACR,UAAU,CAAC,KAAK,EAChB,GAAG,EAAE,CAAC,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAC3D,CAAC;oBACN,CAAC;gBAEL,CAAC,CAAC;gBACF,QAAQ,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,UAAU,EAAC,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;QAEL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -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,20 +37,18 @@ 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;
|
|
@@ -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;
|