@qavajs/cypress-runner-adapter 1.8.0 → 1.9.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/adapter/index.js CHANGED
@@ -1,4 +1,5 @@
1
- const { ensureFileSync, writeFileSync, readFileSync } = require('fs-extra');
1
+ const { mkdirSync, writeFileSync, readFileSync } = require('node:fs');
2
+ const { dirname } = require('node:path');
2
3
  const { randomUUID } = require('node:crypto');
3
4
  const { AstBuilder, compile, GherkinClassicTokenMatcher, Parser } = require('@cucumber/gherkin');
4
5
  const webpackPreprocessor = require('@cypress/webpack-preprocessor')();
@@ -26,7 +27,7 @@ module.exports = async function cucumber(file) {
26
27
  const tagExpression = tagExpressionParser(process.env.TAGS || '');
27
28
  const testCases = compile(gherkinDocument, filePath, uuidFn)
28
29
  .filter(test => tagExpression.evaluate(test.tags.map(tag => tag.name)));
29
- ensureFileSync(outputPath);
30
+ mkdirSync(dirname(outputPath), { recursive: true });
30
31
  writeFileSync(outputPath, adapter(testCases), 'utf-8');
31
32
  return outputPath;
32
33
  }
@@ -60,11 +60,22 @@ module.exports = function makeMochaTest(tests) {
60
60
 
61
61
  supportCodeLibrary.World.prototype.executeStep = executeStepByText;
62
62
 
63
- function runStep(name, callback) {
63
+ function runStep({ keyword, name }, callback) {
64
+ const displayName = keyword ? keyword : name;
65
+ const message = keyword && name ? name : '';
66
+ let group;
64
67
  cy.then(() => {
65
- Cypress.log({ displayName: name, message: '' });
66
- })
68
+ group = Cypress.log({
69
+ name,
70
+ displayName,
71
+ message,
72
+ groupStart: true,
73
+ });
74
+ });
67
75
  callback();
76
+ cy.then(() => {
77
+ group.endGroup();
78
+ });
68
79
  }
69
80
 
70
81
  function findTest(tests, name) {
@@ -94,7 +105,7 @@ module.exports = function makeMochaTest(tests) {
94
105
  });
95
106
  for (const beforeTest of supportCodeLibrary.beforeTestCaseHookDefinitions) {
96
107
  if (beforeTest.appliesToTestCase(test)) {
97
- runStep(beforeTest.name, function () {
108
+ runStep({ name: beforeTest.name }, function () {
98
109
  beforeTest.code.apply(world, [{
99
110
  pickle: test,
100
111
  gherkinDocument: tests,
@@ -127,7 +138,7 @@ module.exports = function makeMochaTest(tests) {
127
138
  }
128
139
  for (const afterTest of supportCodeLibrary.afterTestCaseHookDefinitions) {
129
140
  if (afterTest.appliesToTestCase(test)) {
130
- runStep(afterTest.name, function () {
141
+ runStep({ name: afterTest.name }, function () {
131
142
  afterTest.code.apply(world, [{
132
143
  pickle: test,
133
144
  result,
@@ -144,8 +155,7 @@ module.exports = function makeMochaTest(tests) {
144
155
  it('Scenario: ' + test.name, function () {
145
156
  const world = this.world;
146
157
  for (const step of test.steps) {
147
- const stepName = `${keyword(step)} ${stepNameText(step)}`;
148
- runStep(stepName, function () {
158
+ runStep({ keyword: keyword(step), name: stepNameText(step) }, () => {
149
159
  this.step = step;
150
160
  const result = { status: 'passed', duration: 0 };
151
161
  for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
package/adapter.d.ts CHANGED
@@ -1 +1 @@
1
- export default function (file: any): void;
1
+ export default function (file: any): Promise<any>;
package/index.d.ts CHANGED
@@ -35,5 +35,6 @@ export class World {
35
35
  log: (...args: any) => void;
36
36
  attach: (...args: any) => void;
37
37
  link: (...args: any) => void;
38
+ executeStep: (...args: any) => Promise<any>;
38
39
  });
39
40
  }
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@qavajs/cypress-runner-adapter",
3
- "version": "1.8.0",
3
+ "version": "1.9.1",
4
4
  "main": "index.js",
5
+ "files": [
6
+ "adapter",
7
+ "supportCodeLibrary",
8
+ "index.js",
9
+ "index.d.ts",
10
+ "adapter.js",
11
+ "adapter.d.ts"
12
+ ],
5
13
  "scripts": {
6
14
  "debug": "cypress open --config-file test/cypress.config.js",
7
15
  "test": "cypress run --config-file test/cypress.config.js",
@@ -25,11 +33,10 @@
25
33
  "@cucumber/cucumber-expressions": "^19.0.0",
26
34
  "@cucumber/gherkin": "^39.0.0",
27
35
  "@cucumber/tag-expressions": "^9.1.0",
28
- "@cypress/webpack-preprocessor": "^7.0.2",
29
- "fs-extra": "^11.3.3"
36
+ "@cypress/webpack-preprocessor": "^7.0.2"
30
37
  },
31
38
  "devDependencies": {
32
- "cypress": "^15.11.0",
39
+ "cypress": "^15.12.0",
33
40
  "mochawesome": "^7.1.4"
34
41
  },
35
42
  "keywords": [
@@ -42,4 +49,4 @@
42
49
  "test",
43
50
  "test-automation"
44
51
  ]
45
- }
52
+ }
@@ -47,6 +47,6 @@ export default class DataTable {
47
47
  const transposed = this.rawTable[0].map((x, i) =>
48
48
  this.rawTable.map((y) => y[i])
49
49
  )
50
- return new Data_table(transposed)
50
+ return new DataTable(transposed)
51
51
  }
52
52
  }
@@ -52,8 +52,7 @@ export function Given(pattern, code) {
52
52
  }
53
53
 
54
54
  export function Before(optionsOrCode, code) {
55
- const defaultOptions = { name: 'Before' };
56
- const options = code ? Object.assign(defaultOptions, optionsOrCode) : defaultOptions;
55
+ const options = code ? Object.assign({ name: 'Before' }, optionsOrCode) : { name: 'Before' };
57
56
  const handler = code ?? optionsOrCode;
58
57
  supportCodeLibrary.beforeTestCaseHookDefinitions.push(new TestCaseHookDefinition({
59
58
  code: handler,
@@ -62,8 +61,7 @@ export function Before(optionsOrCode, code) {
62
61
  }
63
62
 
64
63
  export function After(optionsOrCode, code) {
65
- const defaultOptions = { name: 'After' };
66
- const options = code ? Object.assign(defaultOptions, optionsOrCode) : defaultOptions;
64
+ const options = code ? Object.assign({ name: 'After' }, optionsOrCode) : { name: 'After' };
67
65
  const handler = code ?? optionsOrCode;
68
66
  supportCodeLibrary.afterTestCaseHookDefinitions.push(new TestCaseHookDefinition({
69
67
  code: handler,
package/CHANGELOG.md DELETED
@@ -1,79 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to the "@qavajs/cypress-runner-adapter" will be documented in this file.
4
-
5
- Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6
-
7
- :rocket: - new feature
8
-
9
- :beetle: - bugfix
10
-
11
- :x: - deprecation/removal
12
-
13
- :pencil: - chore
14
-
15
- :microscope: - experimental
16
-
17
- ## [1.8.0]
18
- - :rocket: added `testCaseStartedId` and `testStepId` as hooks parameters to comply cucumber spec
19
-
20
- ## [1.7.0]
21
- - :rocket: updated @cucumber/cucumber-expressions, @cucumber/gherkin, @cucumber/tag-expressions
22
-
23
- ## [1.6.0]
24
- - :rocket: updated logs for Gherkin steps
25
- - :rocket: improved multi line and data table step logging
26
-
27
- ## [1.5.0]
28
- - :rocket: added `world.log` method
29
- - :rocket: updated test.body to render corresponding step code
30
-
31
- ## [1.4.2]
32
- - :pencil: updated to cypress 15.7.0
33
- - :pencil: updated to gherkin to 37.0.0
34
-
35
- ## [1.4.1]
36
- - :beetle: fixed `result` property in `After` and `AfterStep` hooks
37
- - :rocket: added workaround to complete `AfterStep` hook in case of step fail
38
-
39
- ## [1.4.0]
40
- - :rocket: added `Template` utility function
41
- ```typescript
42
- import { When, Template } from '@qavajs/playwright-runner-adapter';
43
-
44
- When('I click {string} and verify {string}', Template((locator, expected) => `
45
- I click '${locator}'
46
- I expect '${locator} > Value' to equal '${expected}'
47
- `));
48
- ```
49
-
50
- ## [1.3.0]
51
- - :rocket: added tags support
52
- - :rocket: added alternative 'it mode' to translate gherkin tests to mocha `it` instead of `describe`
53
- ```bash
54
- MODE=it npx cypress open
55
- ```
56
-
57
- ## [1.2.1]
58
- - :pencil: updated to cypress 15.3
59
-
60
- ## [1.2.0]
61
- - :pencil: updated to cypress 15
62
-
63
- ## [1.1.0]
64
- - :pencil: updated to cypress 14
65
-
66
- ## [1.0.1]
67
- - :pencil: updated dependencies
68
-
69
- ## [1.0.0]
70
- - :rocket: added `this.executeStep` world method
71
-
72
- ## [0.2.0]
73
- - :rocket: added _BeforeAll_ and _AfterAll_ hooks support
74
-
75
- ## [0.1.1]
76
- - :beetle: changed browserify to webpack
77
-
78
- ## [0.1.0]
79
- - :rocket: initial implementation