@qavajs/cypress-runner-adapter 1.3.0 → 1.4.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
@@ -14,6 +14,17 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
14
14
 
15
15
  :microscope: - experimental
16
16
 
17
+ ## [1.4.0]
18
+ - :rocket: added `Template` utility function
19
+ ```typescript
20
+ import { When, Template } from '@qavajs/playwright-runner-adapter';
21
+
22
+ When('I click {string} and verify {string}', Template((locator, expected) => `
23
+ I click '${locator}'
24
+ I expect '${locator} > Value' to equal '${expected}'
25
+ `));
26
+ ```
27
+
17
28
  ## [1.3.0]
18
29
  - :rocket: added tags support
19
30
  - :rocket: added alternative 'it mode' to translate gherkin tests to mocha `it` instead of `describe`
package/index.d.ts CHANGED
@@ -29,3 +29,4 @@ export function BeforeAll(fn: Function): void;
29
29
  export function AfterAll(fn: Function): void;
30
30
  export function setWorldConstructor(world: IWorld): void;
31
31
  export function defineParameterType(option: ParameterTypeOption): void;
32
+ export function Template(template: (...args: any[]) => string): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qavajs/cypress-runner-adapter",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "debug": "cypress open --config-file test/cypress.config.js",
@@ -20,16 +20,16 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/qavajs/cypress-runner-adapter/issues"
22
22
  },
23
- "homepage": "https://github.com/qavajs/cypress-runner-adaptert#readme",
23
+ "homepage": "https://qavajs.github.io/docs/intro",
24
24
  "dependencies": {
25
25
  "@cucumber/cucumber-expressions": "^18.0.1",
26
- "@cucumber/gherkin": "^35.1.0",
27
- "@cucumber/tag-expressions": "^7.0.0",
26
+ "@cucumber/gherkin": "^36.0.0",
27
+ "@cucumber/tag-expressions": "^8.0.0",
28
28
  "@cypress/webpack-preprocessor": "^7.0.1",
29
29
  "fs-extra": "^11.3.2"
30
30
  },
31
31
  "devDependencies": {
32
- "cypress": "^15.3.0"
32
+ "cypress": "^15.5.0"
33
33
  },
34
34
  "keywords": [
35
35
  "cypress",
@@ -103,4 +103,28 @@ export function defineParameterType(options) {
103
103
  supportCodeLibrary.parameterTypeRegistry.defineSourcedParameterType(parameterType, {})
104
104
  }
105
105
 
106
+ /**
107
+ * Define template step
108
+ * @param {() => string} scenario - multiline string with steps
109
+ * @example
110
+ * When('I click {string} and verify {string}', Template((locator, expected) => `
111
+ * I click '${locator}'
112
+ * I expect '${locator} > Value' to equal '${expected}'
113
+ * `));
114
+ */
115
+ export function Template(scenario) {
116
+ return new Proxy(scenario, {
117
+ apply: function (template, world, args) {
118
+ const scenario = template(...args) ;
119
+ const steps = scenario
120
+ .split('\n')
121
+ .map(step => step.trim())
122
+ .filter(Boolean);
123
+ for (const step of steps) {
124
+ world.executeStep(step);
125
+ }
126
+ },
127
+ })
128
+ }
129
+
106
130