@qavajs/playwright-runner-adapter 1.1.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -10,6 +10,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
10
10
  :pencil: - chore
11
11
  :microscope: - experimental
12
12
 
13
+ ## [1.2.0]
14
+ - :rocket: reworked hooks via playwright hooks
15
+ - :rocket: display proper location in sources
16
+
17
+ ## [1.1.1]
18
+ - :beetle: fixed issue with After hooks execution in case of failed test
19
+
13
20
  ## [1.1.0]
14
21
  - :rocket: improved BeforeStep/AfterStep logging
15
22
  - :beetle: fixed BeforeAll/AfterAll behavior
@@ -13,9 +13,12 @@ function attach(body, details) {
13
13
  }
14
14
  const fixture = new supportCodeLibrary.World({});
15
15
  const test = fixture.test;
16
- for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
17
- test.beforeAll(() => beforeAllHook.code.apply({}));
18
- }
16
+ test.beforeAll(async () => {
17
+ for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
18
+ const location = { location: { column: 1, file: beforeAllHook.uri, line: beforeAllHook.line } };
19
+ await test.step('Before All', () => beforeAllHook.code.apply({}), location);
20
+ }
21
+ });
19
22
  for (const feature of features) {
20
23
  const tests = feature.tests;
21
24
  test.describe(feature.feature, async () => {
@@ -24,37 +27,57 @@ for (const feature of features) {
24
27
  attach,
25
28
  supportCodeLibrary
26
29
  });
27
- test.beforeEach(world.init);
30
+ test.beforeEach('Fixtures', world.init);
31
+ test.beforeEach('Before Hooks', async () => {
32
+ var _a;
33
+ const testId = test
34
+ .info()
35
+ .annotations
36
+ .find((annotation) => annotation.type === 'testId')
37
+ .description;
38
+ const testCase = tests.find(test => test.id === testId);
39
+ for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
40
+ if (beforeHook.appliesToTestCase(testCase)) {
41
+ const hookName = (_a = beforeHook.name) !== null && _a !== void 0 ? _a : 'Before';
42
+ const location = { location: { column: 1, file: beforeHook.uri, line: beforeHook.line } };
43
+ await test.step(hookName, () => beforeHook.code.apply(world, [{
44
+ pickle: testCase
45
+ }]), location);
46
+ }
47
+ }
48
+ });
28
49
  for (const testCase of tests) {
29
50
  const tag = testCase.tags.map((tag) => tag.name);
30
- test(testCase.name, { tag }, async () => {
31
- var _a, _b;
32
- const result = { status: 'passed' };
33
- for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
34
- if (beforeHook.appliesToTestCase(testCase)) {
35
- const hookName = (_a = beforeHook.name) !== null && _a !== void 0 ? _a : 'Before';
36
- await test.step(hookName, () => beforeHook.code.apply(world, [{
37
- pickle: testCase
38
- }]));
39
- }
40
- }
51
+ const annotation = [
52
+ { type: 'name', description: testCase.name },
53
+ { type: 'testId', description: testCase.id },
54
+ { type: 'tags', description: JSON.stringify(testCase.tags) }
55
+ ];
56
+ test(testCase.name, { tag, annotation: annotation }, async () => {
57
+ const testInfo = test.info();
58
+ testInfo.result = { status: 'passed' };
41
59
  for (const pickleStep of testCase.steps) {
60
+ if (testInfo.error) {
61
+ break;
62
+ }
63
+ const steps = supportCodeLibrary.stepDefinitions
64
+ .filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
65
+ if (steps.length === 0)
66
+ throw new Error(`Step '${pickleStep.text}' is not defined`);
67
+ if (steps.length > 1)
68
+ throw new Error(`'${pickleStep.text}' matches multiple step definitions`);
69
+ const [step] = steps;
70
+ const location = { location: { column: 1, file: step.uri, line: step.line } };
42
71
  await test.step(pickleStep.text, async () => {
43
72
  for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
44
73
  if (beforeStep.appliesToTestCase(testCase)) {
74
+ const location = { location: { column: 1, file: beforeStep.uri, line: beforeStep.line } };
45
75
  await test.step('Before Step', () => beforeStep.code.apply(world, [{
46
76
  pickle: testCase,
47
77
  pickleStep
48
- }]));
78
+ }]), location);
49
79
  }
50
80
  }
51
- const steps = supportCodeLibrary.stepDefinitions
52
- .filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
53
- if (steps.length === 0)
54
- throw new Error(`Step '${pickleStep.text}' is not defined`);
55
- if (steps.length > 1)
56
- throw new Error(`'${pickleStep.text}' matches multiple step definitions`);
57
- const [step] = steps;
58
81
  const { parameters } = await step.getInvocationParameters({
59
82
  step: {
60
83
  text: pickleStep.text,
@@ -66,35 +89,50 @@ for (const feature of features) {
66
89
  await step.code.apply(world, parameters);
67
90
  }
68
91
  catch (err) {
69
- result.status = 'failed';
70
- result.error = err;
92
+ testInfo.result.error = err;
93
+ throw err;
71
94
  }
72
- for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
73
- if (afterStep.appliesToTestCase(testCase)) {
74
- await test.step('After Step', () => afterStep.code.apply(world, [{
75
- pickle: testCase,
76
- pickleStep,
77
- result
78
- }]));
95
+ finally {
96
+ for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
97
+ if (afterStep.appliesToTestCase(testCase)) {
98
+ const location = { location: { column: 1, file: afterStep.uri, line: afterStep.line } };
99
+ await test.step('After Step', () => afterStep.code.apply(world, [{
100
+ pickle: testCase,
101
+ pickleStep,
102
+ result: testInfo.result
103
+ }]), location);
104
+ }
79
105
  }
80
106
  }
81
- if (result.error)
82
- throw result.error;
83
- });
84
- }
85
- for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
86
- if (afterHook.appliesToTestCase(testCase)) {
87
- const hookName = (_b = afterHook.name) !== null && _b !== void 0 ? _b : 'After';
88
- await test.step(hookName, () => afterHook.code.apply(world, [{
89
- pickle: testCase, result
90
- }]));
91
- }
107
+ }, location);
92
108
  }
93
109
  });
94
110
  }
111
+ test.afterEach('After Hooks', async () => {
112
+ var _a;
113
+ const testInfo = test.info();
114
+ const testId = testInfo
115
+ .annotations
116
+ .find((annotation) => annotation.type === 'testId')
117
+ .description;
118
+ const testCase = tests.find(test => test.id === testId);
119
+ for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
120
+ if (afterHook.appliesToTestCase(testCase)) {
121
+ const hookName = (_a = afterHook.name) !== null && _a !== void 0 ? _a : 'After';
122
+ const location = { location: { column: 1, file: afterHook.uri, line: afterHook.line } };
123
+ await test.step(hookName, () => afterHook.code.apply(world, [{
124
+ pickle: testCase,
125
+ result: testInfo.result
126
+ }]), location);
127
+ }
128
+ }
129
+ });
95
130
  });
96
131
  }
97
- for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
98
- test.afterAll(() => afterAllHook.code.apply({}));
99
- }
132
+ test.afterAll(async () => {
133
+ for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
134
+ const location = { location: { column: 1, file: afterAllHook.uri, line: afterAllHook.line } };
135
+ await test.step('After All', () => afterAllHook.code.apply({}), location);
136
+ }
137
+ });
100
138
  //# sourceMappingURL=cucumber.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cucumber.spec.js","sourceRoot":"","sources":["../src/cucumber.spec.ts"],"names":[],"mappings":";;AAAA,qCAAgC;AAEhC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,IAAA,aAAI,GAAE,CAAC;AAEhD,SAAS,GAAG,CAAC,IAAS;IAClB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,MAAM,CAAsB,IAAS,EAAE,OAAY;;IACxD,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,YAAY,CAAC;IAClD,MAAM,WAAW,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,YAAY,CAAC;IACtD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACjD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,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACxC,MAAM,QAAQ,GAAG,MAAA,SAAS,CAAC,IAAI,mCAAI,OAAO,CAAC;oBAC3C,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,EAAC,CAAA;oBACtF,MAAM,IAAI,CAAC,IAAI,CACX,QAAQ,EACR,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;4BAC/B,MAAM,EAAE,QAAQ;4BAChB,MAAM,EAAE,QAAQ,CAAC,MAAM;yBAC1B,CAAC,CAAC,EACH,QAAQ,CACX,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;IACrB,KAAK,MAAM,YAAY,IAAI,kBAAkB,CAAC,2BAA2B,EAAE,CAAC;QACxE,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,EAAC,CAAA;QAC5F,MAAM,IAAI,CAAC,IAAI,CACX,WAAW,EACX,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EACjC,QAAQ,CACX,CAAA;IACL,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/playwright-runner-adapter",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "adapter for playwright test runner",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -11,12 +11,12 @@
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
13
  "@cucumber/gherkin": "^30.0.4",
14
- "glob": "^11.0.0"
14
+ "glob": "^11.0.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@cucumber/cucumber": "^11.1.1",
17
+ "@cucumber/cucumber": "^11.2.0",
18
18
  "@playwright/test": "^1.49.1",
19
- "@types/node": "^22.10.5",
20
- "typescript": "^5.7.2"
19
+ "@types/node": "^22.10.6",
20
+ "typescript": "^5.7.3"
21
21
  }
22
22
  }
@@ -1,6 +1,6 @@
1
1
  import { load } from './loader';
2
2
 
3
- const { features, supportCodeLibrary } = load();
3
+ const { features, supportCodeLibrary} = load();
4
4
 
5
5
  function log(data: any) {
6
6
  console.log(data);
@@ -15,9 +15,16 @@ function attach(this: { test: any }, body: any, details: any) {
15
15
  const fixture = new supportCodeLibrary.World({});
16
16
  const test = fixture.test;
17
17
 
18
- for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
19
- test.beforeAll(() => beforeAllHook.code.apply({}));
20
- }
18
+ test.beforeAll(async () => {
19
+ for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
20
+ const location = { location: { column: 1, file: beforeAllHook.uri, line: beforeAllHook.line }}
21
+ await test.step(
22
+ 'Before All',
23
+ () => beforeAllHook.code.apply({}),
24
+ location
25
+ )
26
+ }
27
+ });
21
28
 
22
29
  for (const feature of features) {
23
30
  const tests = feature.tests;
@@ -28,36 +35,65 @@ for (const feature of features) {
28
35
  supportCodeLibrary
29
36
  });
30
37
 
31
- test.beforeEach(world.init);
38
+ test.beforeEach('Fixtures', world.init);
32
39
 
33
- for (const testCase of tests) {
34
- const tag = testCase.tags.map((tag: { name: string }) => tag.name);
35
- test(testCase.name, { tag }, async () => {
36
- const result: { status: string, error?: any } = { status: 'passed' };
37
- for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
38
- if (beforeHook.appliesToTestCase(testCase)) {
39
- const hookName = beforeHook.name ?? 'Before';
40
- await test.step(hookName, () => beforeHook.code.apply(world, [{
40
+ test.beforeEach('Before Hooks', async () => {
41
+ const testId = test
42
+ .info()
43
+ .annotations
44
+ .find((annotation: { type: string }) => annotation.type === 'testId')
45
+ .description;
46
+ const testCase = tests.find(test => test.id === testId);
47
+ for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
48
+ if (beforeHook.appliesToTestCase(testCase)) {
49
+ const hookName = beforeHook.name ?? 'Before';
50
+ const location = { location: { column: 1, file: beforeHook.uri, line: beforeHook.line }}
51
+ await test.step(
52
+ hookName,
53
+ () => beforeHook.code.apply(world, [{
41
54
  pickle: testCase
42
- }]));
43
- }
55
+ }]),
56
+ location
57
+ );
44
58
  }
59
+ }
60
+ });
61
+
62
+ for (const testCase of tests) {
63
+ const tag = testCase.tags.map((tag: { name: string }) => tag.name);
64
+ const annotation = [
65
+ { type: 'name', description: testCase.name },
66
+ { type: 'testId', description: testCase.id },
67
+ { type: 'tags', description: JSON.stringify(testCase.tags) }
68
+ ];
69
+ test(testCase.name, { tag, annotation: annotation }, async () => {
70
+ const testInfo = test.info();
71
+ testInfo.result = { status: 'passed' };
45
72
  for (const pickleStep of testCase.steps) {
73
+ if (testInfo.error) {
74
+ break;
75
+ }
76
+ const steps = supportCodeLibrary.stepDefinitions
77
+ .filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
78
+ if (steps.length === 0) throw new Error(`Step '${pickleStep.text}' is not defined`);
79
+ if (steps.length > 1) throw new Error(`'${pickleStep.text}' matches multiple step definitions`);
80
+ const [ step ] = steps;
81
+ const location = { location: { column: 1, file: step.uri, line: step.line }}
46
82
  await test.step(pickleStep.text, async () => {
47
83
  for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
48
84
  if (beforeStep.appliesToTestCase(testCase)) {
49
- await test.step('Before Step', () => beforeStep.code.apply(world, [{
50
- pickle: testCase,
51
- pickleStep
52
- }]));
85
+ const location = { location: { column: 1, file: beforeStep.uri, line: beforeStep.line }}
86
+ await test.step(
87
+ 'Before Step',
88
+ () => beforeStep.code.apply(world, [{
89
+ pickle: testCase,
90
+ pickleStep
91
+ }]),
92
+ location
93
+ );
53
94
  }
54
95
  }
55
- const steps = supportCodeLibrary.stepDefinitions
56
- .filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
57
- if (steps.length === 0) throw new Error(`Step '${pickleStep.text}' is not defined`);
58
- if (steps.length > 1) throw new Error(`'${pickleStep.text}' matches multiple step definitions`);
59
- const [ step ] = steps;
60
- const { parameters} = await step.getInvocationParameters({
96
+ const { parameters } = await step.getInvocationParameters({
61
97
  step: {
62
98
  text: pickleStep.text,
63
99
  argument: pickleStep.argument
@@ -66,35 +102,63 @@ for (const feature of features) {
66
102
  } as any);
67
103
  try {
68
104
  await step.code.apply(world, parameters);
69
- } catch (err) {
70
- result.status = 'failed';
71
- result.error = err;
72
- }
73
- for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
74
- if (afterStep.appliesToTestCase(testCase)) {
75
- await test.step('After Step', () => afterStep.code.apply(world, [{
76
- pickle: testCase,
77
- pickleStep,
78
- result
79
- }]));
105
+ } catch (err: any) {
106
+ testInfo.result.error = err;
107
+ throw err;
108
+ } finally {
109
+ for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
110
+ if (afterStep.appliesToTestCase(testCase)) {
111
+ const location = { location: { column: 1, file: afterStep.uri, line: afterStep.line }}
112
+ await test.step(
113
+ 'After Step',
114
+ () => afterStep.code.apply(world, [{
115
+ pickle: testCase,
116
+ pickleStep,
117
+ result: testInfo.result
118
+ }]),
119
+ location
120
+ );
121
+ }
80
122
  }
81
123
  }
82
- if (result.error) throw result.error;
83
- });
84
- }
85
- for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
86
- if (afterHook.appliesToTestCase(testCase)) {
87
- const hookName = afterHook.name ?? 'After';
88
- await test.step(hookName, () => afterHook.code.apply(world, [{
89
- pickle: testCase, result
90
- }]));
91
- }
124
+ }, location);
92
125
  }
93
126
  })
94
127
  }
128
+
129
+ test.afterEach('After Hooks', async () => {
130
+ const testInfo = test.info();
131
+ const testId = testInfo
132
+ .annotations
133
+ .find((annotation: { type: string }) => annotation.type === 'testId')
134
+ .description;
135
+ const testCase = tests.find(test => test.id === testId);
136
+ for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
137
+ if (afterHook.appliesToTestCase(testCase)) {
138
+ const hookName = afterHook.name ?? 'After';
139
+ const location = { location: { column: 1, file: afterHook.uri, line: afterHook.line }}
140
+ await test.step(
141
+ hookName,
142
+ () => afterHook.code.apply(world, [{
143
+ pickle: testCase,
144
+ result: testInfo.result
145
+ }]),
146
+ location
147
+ );
148
+ }
149
+ }
150
+ });
151
+
95
152
  });
96
153
  }
97
154
 
98
- for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
99
- test.afterAll(() => afterAllHook.code.apply({}));
100
- }
155
+ test.afterAll(async () => {
156
+ for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
157
+ const location = { location: { column: 1, file: afterAllHook.uri, line: afterAllHook.line }}
158
+ await test.step(
159
+ 'After All',
160
+ () => afterAllHook.code.apply({}),
161
+ location
162
+ )
163
+ }
164
+ });