@qavajs/cypress-runner-adapter 0.1.1 → 1.0.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
@@ -5,11 +5,21 @@ All notable changes to the "@qavajs/cypress-runner-adapter" will be documented i
5
5
  Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6
6
 
7
7
  :rocket: - new feature
8
+
8
9
  :beetle: - bugfix
10
+
9
11
  :x: - deprecation/removal
12
+
10
13
  :pencil: - chore
14
+
11
15
  :microscope: - experimental
12
16
 
17
+ ## [1.0.0]
18
+ - :rocket: added `this.executeStep` world method
19
+
20
+ ## [0.2.0]
21
+ - :rocket: added _BeforeAll_ and _AfterAll_ hooks support
22
+
13
23
  ## [0.1.1]
14
24
  - :beetle: changed browserify to webpack
15
25
 
package/adapter/index.js CHANGED
@@ -25,6 +25,19 @@ function adapter(testCases) {
25
25
  }
26
26
  }
27
27
 
28
+ function executeStepByText(text, argument) {
29
+ const steps = supportCodeLibrary.stepDefinitions
30
+ .filter(stepDefinition => stepDefinition.matchesStepName(text));
31
+ if (steps.length === 0) throw new Error(\`Step '\${text}' is not defined\`);
32
+ if (steps.length > 1) throw new Error(\`Step '\${text}' matches multiple step definitions\`);
33
+ const [step] = steps;
34
+ const { parameters } = step.getInvocationParameters({
35
+ step: { text, argument },
36
+ world: this
37
+ });
38
+ step.code.apply(this, parameters);
39
+ }
40
+
28
41
  function executeStep(pickle, world) {
29
42
  if (pickle.argument && pickle.argument.dataTable) {
30
43
  Cypress.log({ displayName: 'DataTable', message: pickle.argument.dataTable })
@@ -32,23 +45,22 @@ function adapter(testCases) {
32
45
  if (pickle.argument && pickle.argument.docString) {
33
46
  Cypress.log({ displayName: 'Multiline', message: pickle.argument.docString.content })
34
47
  }
35
- const steps = supportCodeLibrary.stepDefinitions
36
- .filter(stepDefinition => stepDefinition.matchesStepName(pickle.text));
37
- if (steps.length === 0) throw new Error(\`Step '\${pickle.text}' is not defined\`);
38
- if (steps.length > 1) throw new Error(\`'\${pickle.text}' matches multiple step definitions\`);
39
- const [step] = steps;
40
- const { parameters } = step.getInvocationParameters({
41
- step: {
42
- text: pickle.text,
43
- argument: pickle.argument
44
- },
45
- world
46
- });
47
- step.code.apply(world, parameters);
48
+ executeStepByText.call(world, pickle.text, pickle.argument);
49
+ }
50
+
51
+ if (supportCodeLibrary.beforeTestRunHookDefinitions.length > 0) {
52
+ describe('Before All', function () {
53
+ for (const beforeRun of supportCodeLibrary.beforeTestRunHookDefinitions) {
54
+ it('Before All', function () {
55
+ beforeRun.code.apply();
56
+ });
57
+ }
58
+ })
48
59
  }
49
60
  for (const test of tests) {
50
61
  describe('Scenario: ' + test.name, { testIsolation: false }, function () {
51
62
  const world = new supportCodeLibrary.World();
63
+ world.executeStep = executeStepByText;
52
64
  let skip = false;
53
65
  let result = 'passed';
54
66
  afterEach(function() {
@@ -60,7 +72,7 @@ function adapter(testCases) {
60
72
  pickleStep: this.step,
61
73
  gherkinDocument: tests,
62
74
  result: this.currentTest.state
63
- }])
75
+ }]);
64
76
  }
65
77
  }
66
78
  }
@@ -105,11 +117,20 @@ function adapter(testCases) {
105
117
  result,
106
118
  gherkinDocument: tests,
107
119
  willBeRetried: false
108
- }])
120
+ }]);
109
121
  });
110
122
  }
111
123
  }
112
124
  });
125
+ }
126
+ if (supportCodeLibrary.afterTestRunHookDefinitions.length > 0) {
127
+ describe('After All', function () {
128
+ for (const afterRun of supportCodeLibrary.afterTestRunHookDefinitions) {
129
+ it('After All', function () {
130
+ afterRun.code.apply();
131
+ });
132
+ }
133
+ })
113
134
  }
114
135
  `;
115
136
  }
package/index.d.ts CHANGED
@@ -25,5 +25,7 @@ export function BeforeStep(fn: Function): void;
25
25
  export function BeforeStep(options: StepHookOptions, fn: Function): void;
26
26
  export function AfterStep(fn: Function): void;
27
27
  export function AfterStep(options: StepHookOptions, fn: Function): void;
28
+ export function BeforeAll(fn: Function): void;
29
+ export function AfterAll(fn: Function): void;
28
30
  export function setWorldConstructor(world: IWorld): void;
29
31
  export function defineParameterType(option: ParameterTypeOption): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/cypress-runner-adapter",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "debug": "cypress open --config-file test/cypress.config.js",
@@ -10,13 +10,13 @@
10
10
  "license": "MIT",
11
11
  "description": "feature file preprocessor",
12
12
  "dependencies": {
13
- "@cucumber/cucumber-expressions": "^17.1.0",
14
- "@cucumber/gherkin": "^28.0.0",
15
- "@cucumber/tag-expressions": "^6.1.0",
13
+ "@cucumber/cucumber-expressions": "^18.0.1",
14
+ "@cucumber/gherkin": "^30.0.4",
15
+ "@cucumber/tag-expressions": "^6.1.1",
16
16
  "@cypress/webpack-preprocessor": "^6.0.2",
17
17
  "fs-extra": "^11.2.0"
18
18
  },
19
19
  "devDependencies": {
20
- "cypress": "^13.11.0"
20
+ "cypress": "^13.16.0"
21
21
  }
22
22
  }
@@ -1,12 +1,10 @@
1
- import {
2
- CucumberExpression,
3
- RegularExpression,
4
- } from '@cucumber/cucumber-expressions'
1
+ import { CucumberExpression, RegularExpression } from '@cucumber/cucumber-expressions'
5
2
  import StepDefinition from './step_definition';
6
- import {SourcedParameterTypeRegistry} from './sourced_parameter_type_registry';
3
+ import { SourcedParameterTypeRegistry } from './sourced_parameter_type_registry';
7
4
  import TestCaseHookDefinition from './test_case_hook_definition';
8
5
  import TestStepHookDefinition from './test_step_hook_definition';
9
- import {buildParameterType} from './build_parameter_type';
6
+ import { buildParameterType } from './build_parameter_type';
7
+ import TestRunHookDefinition from './test_run_hook_definition';
10
8
  class World {}
11
9
 
12
10
  const supportCodeLibrary = {
@@ -84,6 +82,18 @@ export function AfterStep(optionsOrCode, code) {
84
82
  }));
85
83
  }
86
84
 
85
+ export function BeforeAll(handler) {
86
+ supportCodeLibrary.beforeTestRunHookDefinitions.push(new TestRunHookDefinition({
87
+ code: handler,
88
+ }));
89
+ }
90
+
91
+ export function AfterAll(handler) {
92
+ supportCodeLibrary.afterTestRunHookDefinitions.push(new TestRunHookDefinition({
93
+ code: handler,
94
+ }));
95
+ }
96
+
87
97
  export function setWorldConstructor(world) {
88
98
  supportCodeLibrary.World = world;
89
99
  }
@@ -0,0 +1,3 @@
1
+ import Definition from './definition'
2
+
3
+ export default class TestRunHookDefinition extends Definition {}