@qavajs/cypress-runner-adapter 1.9.2 → 1.10.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.
@@ -3,6 +3,21 @@ module.exports = function makeMochaTest(tests) {
3
3
  cy.log(data);
4
4
  }
5
5
 
6
+ function attach(data, options) {
7
+ const type = typeof options === 'string' ? options : options?.mediaType ? options.mediaType : 'text/plain';
8
+ const name = options?.name ?? 'attachment';
9
+ const src = typeof data === 'string' && data.startsWith('data:')
10
+ ? data
11
+ : `data:${type};base64,${btoa(unescape(encodeURIComponent(String(data))))}`;
12
+ cy.then(() => {
13
+ Cypress.log({
14
+ displayName: name,
15
+ message: type,
16
+ consoleProps: () => ({ name, src })
17
+ });
18
+ });
19
+ }
20
+
6
21
  function keyword(step) {
7
22
  switch (step.type) {
8
23
  case 'Context': return 'Given';
@@ -63,7 +78,7 @@ module.exports = function makeMochaTest(tests) {
63
78
  describe('Scenario: ' + test.name, { testIsolation: false }, function () {
64
79
  const world = new supportCodeLibrary.World({
65
80
  log,
66
- attach: log,
81
+ attach,
67
82
  link: log
68
83
  });
69
84
  world.executeStep = executeStepByText;
@@ -72,12 +87,14 @@ module.exports = function makeMochaTest(tests) {
72
87
  let duration = 0;
73
88
  let exception;
74
89
  let message;
90
+ let willBeRetried = false;
75
91
  afterEach(function () {
76
92
  if (this.currentTest.state !== 'passed') {
77
93
  skip = true;
78
94
  }
79
95
  duration += this.currentTest.duration;
80
96
  if (this.currentTest.state === 'failed') {
97
+ willBeRetried = this.currentTest.currentRetry() < this.currentTest._retries;
81
98
  status = this.currentTest.state;
82
99
  exception = this.currentTest.err;
83
100
  message = this.currentTest.err?.message;
@@ -150,7 +167,7 @@ module.exports = function makeMochaTest(tests) {
150
167
  message
151
168
  },
152
169
  gherkinDocument: tests,
153
- willBeRetried: false,
170
+ willBeRetried,
154
171
  testCaseStartedId: test.id,
155
172
  }]);
156
173
  });
@@ -3,6 +3,21 @@ module.exports = function makeMochaTest(tests) {
3
3
  cy.log(data);
4
4
  }
5
5
 
6
+ function attach(data, options) {
7
+ const type = typeof options === 'string' ? options : options?.mediaType ? options.mediaType : 'text/plain';
8
+ const name = options?.name ?? 'attachment';
9
+ const src = typeof data === 'string' && data.startsWith('data:')
10
+ ? data
11
+ : `data:${type};base64,${btoa(unescape(encodeURIComponent(String(data))))}`;
12
+ cy.then(() => {
13
+ Cypress.log({
14
+ displayName: name,
15
+ message: type,
16
+ consoleProps: () => ({ name, src })
17
+ });
18
+ });
19
+ }
20
+
6
21
  function keyword(step) {
7
22
  switch (step.type) {
8
23
  case 'Context':
@@ -100,7 +115,7 @@ module.exports = function makeMochaTest(tests) {
100
115
  this.currentTest.body = renderGherkinTest(test.steps);
101
116
  const world = this.world = new supportCodeLibrary.World({
102
117
  log,
103
- attach: log,
118
+ attach,
104
119
  link: log
105
120
  });
106
121
  for (const beforeTest of supportCodeLibrary.beforeTestCaseHookDefinitions) {
@@ -121,6 +136,7 @@ module.exports = function makeMochaTest(tests) {
121
136
  const test = findTest(tests, this.currentTest.title);
122
137
  const world = this.world;
123
138
  const result = getResult(this.currentTest);
139
+ const willBeRetried = result.status === 'failed' && this.currentTest.currentRetry() < this.currentTest._retries;
124
140
  // corner case to complete AfterStep if test is failed
125
141
  if (result.status === 'failed' && this.step) {
126
142
  for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
@@ -144,7 +160,7 @@ module.exports = function makeMochaTest(tests) {
144
160
  result,
145
161
  gherkinDocument: tests,
146
162
  testCaseStartedId: test.id,
147
- willBeRetried: false
163
+ willBeRetried
148
164
  }]);
149
165
  });
150
166
  }
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@ declare type ParameterTypeOption = {
13
13
  transformer?: Function,
14
14
  useForSnippets?: boolean
15
15
  }
16
+ export function defineStep(keyword: string, expression: Expression, fn: Function): void;
16
17
  export function Given(expression: Expression, fn: Function): void;
17
18
  export function When(expression: Expression, fn: Function): void;
18
19
  export function Then(expression: Expression, fn: Function): void;
@@ -28,6 +29,7 @@ export function BeforeAll(fn: Function): void;
28
29
  export function AfterAll(fn: Function): void;
29
30
  export function setWorldConstructor(world: IWorld): void;
30
31
  export function defineParameterType(option: ParameterTypeOption): void;
32
+ export function setDefaultTimeout(milliseconds: number): void;
31
33
  export function Template(template: (...args: any[]) => string): () => void;
32
34
  export class World {
33
35
  log: (...args: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/cypress-runner-adapter",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "main": "supportCodeLibrary/index.js",
5
5
  "exports": {
6
6
  ".": "./supportCodeLibrary/index.js",
@@ -33,12 +33,12 @@
33
33
  "homepage": "https://qavajs.github.io/docs/intro",
34
34
  "dependencies": {
35
35
  "@cucumber/cucumber-expressions": "^19.0.0",
36
- "@cucumber/gherkin": "^39.0.0",
36
+ "@cucumber/gherkin": "^39.1.0",
37
37
  "@cucumber/tag-expressions": "^9.1.0",
38
38
  "@cypress/webpack-preprocessor": "^7.1.0"
39
39
  },
40
40
  "devDependencies": {
41
- "cypress": "^15.13.0"
41
+ "cypress": "^15.14.2"
42
42
  },
43
43
  "keywords": [
44
44
  "cypress",
@@ -108,6 +108,10 @@ export function defineParameterType(options) {
108
108
  supportCodeLibrary.parameterTypeRegistry.defineSourcedParameterType(parameterType, {})
109
109
  }
110
110
 
111
+ export function setDefaultTimeout(milliseconds) {
112
+ Cypress.config('defaultCommandTimeout', milliseconds);
113
+ }
114
+
111
115
  /**
112
116
  * Define template step
113
117
  * @param {() => string} scenario - multiline string with steps