@dev-blinq/cucumber-js 1.0.0 → 1.0.1-amdocs

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.
Files changed (58) hide show
  1. package/README.md +40 -96
  2. package/bin/cucumber.ts +2 -0
  3. package/bin/download-install.js +175 -0
  4. package/lib/api/convert_configuration.js +1 -0
  5. package/lib/api/convert_configuration.js.map +1 -1
  6. package/lib/api/gherkin.js +81 -0
  7. package/lib/api/gherkin.js.map +1 -1
  8. package/lib/api/run_cucumber.d.ts +1 -1
  9. package/lib/api/run_cucumber.js +10 -10
  10. package/lib/api/run_cucumber.js.map +1 -1
  11. package/lib/api/types.d.ts +5 -3
  12. package/lib/api/types.js.map +1 -1
  13. package/lib/cli/helpers.d.ts +8 -6
  14. package/lib/cli/helpers.js +27 -6
  15. package/lib/cli/helpers.js.map +1 -1
  16. package/lib/cli/index.js +7 -2
  17. package/lib/cli/index.js.map +1 -1
  18. package/lib/configuration/argv_parser.js +4 -2
  19. package/lib/configuration/argv_parser.js.map +1 -1
  20. package/lib/configuration/axios_client.d.ts +1 -0
  21. package/lib/configuration/axios_client.js +40 -0
  22. package/lib/configuration/axios_client.js.map +1 -0
  23. package/lib/configuration/default_configuration.js +2 -0
  24. package/lib/configuration/default_configuration.js.map +1 -1
  25. package/lib/configuration/types.d.ts +2 -0
  26. package/lib/configuration/types.js.map +1 -1
  27. package/lib/formatter/api.d.ts +2 -0
  28. package/lib/formatter/api.js +57 -0
  29. package/lib/formatter/api.js.map +1 -0
  30. package/lib/formatter/bvt_analysis_formatter.d.ts +30 -0
  31. package/lib/formatter/bvt_analysis_formatter.js +342 -0
  32. package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
  33. package/lib/formatter/feature_data_format.d.ts +23 -0
  34. package/lib/formatter/feature_data_format.js +182 -0
  35. package/lib/formatter/feature_data_format.js.map +1 -0
  36. package/lib/formatter/helpers/constants.d.ts +50 -0
  37. package/lib/formatter/helpers/constants.js +60 -0
  38. package/lib/formatter/helpers/constants.js.map +1 -0
  39. package/lib/formatter/helpers/formatters.js +2 -0
  40. package/lib/formatter/helpers/formatters.js.map +1 -1
  41. package/lib/formatter/helpers/report_generator.d.ts +148 -0
  42. package/lib/formatter/helpers/report_generator.js +590 -0
  43. package/lib/formatter/helpers/report_generator.js.map +1 -0
  44. package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
  45. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  46. package/lib/formatter/helpers/upload_serivce.d.ts +26 -0
  47. package/lib/formatter/helpers/upload_serivce.js +237 -0
  48. package/lib/formatter/helpers/upload_serivce.js.map +1 -0
  49. package/lib/formatter/helpers/uploader.d.ts +12 -0
  50. package/lib/formatter/helpers/uploader.js +148 -0
  51. package/lib/formatter/helpers/uploader.js.map +1 -0
  52. package/lib/runtime/test_case_runner.d.ts +1 -0
  53. package/lib/runtime/test_case_runner.js +10 -1
  54. package/lib/runtime/test_case_runner.js.map +1 -1
  55. package/lib/version.d.ts +1 -1
  56. package/lib/version.js +1 -1
  57. package/lib/version.js.map +1 -1
  58. package/package.json +13 -4
package/README.md CHANGED
@@ -1,124 +1,68 @@
1
1
  <h1 align="center">
2
- <img src="./docs/images/logo.svg" alt="">
2
+ <img src="./docs/images/icon.png" style="width:150px;height:150px;" alt="">
3
3
  <br>
4
- Cucumber
4
+ Cucumber - Blinq.io
5
5
  </h1>
6
6
  <p align="center">
7
- <b>Automated tests in plain language, for Node.js</b>
7
+ <b>Cucumber.js with Blinq.io adaptation</b>
8
8
  </p>
9
9
 
10
- [![#StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://vshymanskyy.github.io/StandWithUkraine)
11
- [![npm](https://img.shields.io/npm/v/@cucumber/cucumber.svg)](https://www.npmjs.com/package/@cucumber/cucumber)
12
- [![build](https://github.com/cucumber/cucumber-js/workflows/Build/badge.svg)](https://github.com/cucumber/cucumber-js/actions)
13
- [![coverage](https://coveralls.io/repos/github/cucumber/cucumber-js/badge.svg?branch=master)](https://coveralls.io/github/cucumber/cucumber-js?branch=master)
14
- [![backers](https://opencollective.com/cucumber/backers/badge.svg)](https://opencollective.com/cucumber)
15
- [![sponsors](https://opencollective.com/cucumber/sponsors/badge.svg)](https://opencollective.com/cucumber)
16
-
17
- [Cucumber](https://github.com/cucumber) is a tool for running automated tests written in plain language. Because they're
18
- written in plain language, they can be read by anyone on your team. Because they can be
19
- read by anyone, you can use them to help improve communication, collaboration and trust on
20
- your team.
21
-
22
- This is the JavaScript implementation of Cucumber. It runs on [maintained versions](https://github.com/nodejs/Release) of Node.js. You can [quickly try it via CodeSandbox](https://codesandbox.io/s/cucumber-js-demo-2p3vrl?file=/features/greeting.feature), or read on to get started locally in a couple of minutes.
23
-
24
- Looking to contribute? Read our [code of conduct](https://github.com/cucumber/.github/blob/main/CODE_OF_CONDUCT.md) first, then check the [contributing guide](./CONTRIBUTING.md) to get up and running.
10
+ We took the regular old [Cucumber](https://github.com/cucumber) (A tool for running automated tests) and made improvements
11
+ that could be helpful when working with data that should be saved or when we want to generate fake data for testing
12
+ purposes in our Gherkin feature file.
25
13
 
26
14
  ## Install
27
15
 
28
- Cucumber is [available on npm](https://www.npmjs.com/package/@cucumber/cucumber):
16
+ @dev-blinq/cucumber-js is [available on npm](https://www.npmjs.com/package/@dev-blinq/cucumber-js):
29
17
 
30
18
  ```shell
31
- $ npm install @cucumber/cucumber
19
+ $ npm install @dev-blinq/cucumber-js
32
20
  ```
33
21
 
34
22
  ## Get Started
35
23
 
36
- Let's take this example of something to test:
37
-
38
-
39
- First, write your main code in `src/index.js`:
40
-
41
- ```js
42
- class Greeter {
43
- sayHello() {
44
- return 'hello'
45
- }
46
- }
47
-
48
- module.exports = {
49
- Greeter
50
- }
51
- ```
52
-
53
- Then, write your feature in `features/greeting.feature`:
24
+ Before, we used to write Gherkin feature files like this -
54
25
 
55
26
  ```gherkin
56
- Feature: Greeting
57
-
58
- Scenario: Say hello
59
- When the greeter says hello
60
- Then I should have heard "hello"
27
+ Feature: Github
28
+ Scenario Outline: Create a new repository
29
+ Given Create a new repository name "<repo>"
30
+ Examples:
31
+ | repo
32
+ | random_repo_name
61
33
  ```
62
34
 
63
- Next, implement your steps in `features/support/steps.js`:
35
+ Now, instead of picking a random name by ourselfs, we could fake data using the [faker](https://www.npmjs.com/package/@faker-js/faker) library and get a random value -
64
36
 
65
- ```js
66
- const assert = require('assert')
67
- const { When, Then } = require('@cucumber/cucumber')
68
- const { Greeter } = require('../../src')
69
-
70
- When('the greeter says hello', function () {
71
- this.whatIHeard = new Greeter().sayHello()
72
- });
73
-
74
- Then('I should have heard {string}', function (expectedResponse) {
75
- assert.equal(this.whatIHeard, expectedResponse)
76
- });
37
+ ```gherkin
38
+ Feature: Github
39
+ Scenario Outline: Create a new repository
40
+ Given Create a new repository name "<repo>"
41
+ Examples:
42
+ | repo
43
+ | {{string.alpha(10)}}
77
44
  ```
78
45
 
79
- Finally, run Cucumber:
46
+ We could also save our fake data (or any data really) as a variable for future use using the equals (=) sign -
80
47
 
81
- ```shell
82
- $ npx cucumber-js
48
+ ```gherkin
49
+ Feature: Github
50
+ Scenario Outline: Create a new repository
51
+ Given Create a new repository name "<repo>"
52
+ Examples:
53
+ | repo
54
+ | {{repo=string.alpha(10)}}
55
+
56
+ Scenario Outline: Create a second repository
57
+ Given Create a new repository with the same name as before "<repo>"
58
+ Examples:
59
+ | repo
60
+ | {{repo}}
83
61
  ```
84
62
 
85
- And see the output:
86
-
87
- ![Terminal output showing a successful test run with 1 scenario and 2 steps, all passing](./docs/images/readme-output.png)
88
-
89
- If you learn best by example, we have [a repo with several example projects](https://github.com/cucumber/cucumber-js-examples), that might help you get going.
63
+ In that example, we saved repo as a variable with a value of some fake data and used it again as the second repo
64
+ value, both repos will have the same fake value.
90
65
 
91
66
  ## Documentation
92
67
 
93
- The following documentation is for `main`, which might contain some unreleased features. See [documentation for older versions](./docs/older_versions.md) if you need it.
94
-
95
- * [Installation](./docs/installation.md)
96
- * [CLI](./docs/cli.md)
97
- * [Configuration](./docs/configuration.md)
98
- * Support Code
99
- * [API Reference](./docs/support_files/api_reference.md)
100
- * [Attachments](./docs/support_files/attachments.md)
101
- * [Data Tables](./docs/support_files/data_table_interface.md)
102
- * [Hooks](./docs/support_files/hooks.md)
103
- * [Step Definitions](./docs/support_files/step_definitions.md)
104
- * [Timeouts](./docs/support_files/timeouts.md)
105
- * [World](./docs/support_files/world.md)
106
- * Guides
107
- * [Debugging](./docs/debugging.md)
108
- * [Dry run](./docs/dry_run.md)
109
- * [ES Modules](./docs/esm.md)
110
- * [Failing fast](./docs/fail_fast.md)
111
- * [Filtering which scenarios run](./docs/filtering.md)
112
- * [Formatters for feedback and reporting](./docs/formatters.md)
113
- * [Parallel running for speed](./docs/parallel.md)
114
- * [Profiles for composable configuration](./docs/profiles.md)
115
- * [Rerunning just failures](./docs/rerun.md)
116
- * [Retrying flaky scenarios](./docs/retry.md)
117
- * [JavaScript API for running programmatically](./docs/javascript_api.md)
118
- * [Snippets for undefined steps](./docs/snippets.md)
119
- * [Transpiling (from TypeScript etc)](./docs/transpiling.md)
120
- * [FAQ](./docs/faq.md)
121
-
122
- ## Support
123
-
124
- Support is [available from the community](https://cucumber.io/tools/cucumber-open/support/) if you need it.
68
+ See documentation for the [Blinq.io](https://docs.blinq.io) app.
@@ -0,0 +1,2 @@
1
+ import run from "../src/cli/run";
2
+ run();
@@ -0,0 +1,175 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable no-console */
3
+ /* eslint-disable no-undef */
4
+ const { argv } = require('node:process')
5
+ const fs = require('fs')
6
+ const path = require('path')
7
+ const JSZip = require('jszip')
8
+ const { mkdirSync, writeFileSync } = require('node:fs')
9
+ const axios = require('axios').default
10
+ const tunnel = require('tunnel')
11
+
12
+ let token = null
13
+ let extractPath = null
14
+ const getSSoUrl = () => {
15
+ switch (process.env.NODE_ENV_BLINQ) {
16
+ case 'local':
17
+ return 'http://localhost:5000/api/auth'
18
+ case 'dev':
19
+ return 'https://dev.api.blinq.io/api/auth'
20
+ case 'stage':
21
+ return 'https://stage.api.blinq.io/api/auth'
22
+ case 'prod':
23
+ return 'https://api.blinq.io/api/auth'
24
+ case null:
25
+ return 'https://api.blinq.io/api/auth'
26
+ default:
27
+ return `${process.env.NODE_ENV_BLINQ}/api/auth`
28
+ }
29
+ }
30
+
31
+ const getProxy = () => {
32
+ if (!process.env.PROXY) {
33
+ return null
34
+ }
35
+
36
+ const proxy = process.env.PROXY
37
+ const url = new URL(proxy)
38
+ const proxyObject = {
39
+ host: url.hostname,
40
+ port: Number(url.port),
41
+ }
42
+
43
+ const { username, password } = url
44
+
45
+ if (username && password) {
46
+ proxyObject.proxyAuth = `${username}:${password}`
47
+ }
48
+ return tunnel.httpsOverHttp({ proxy: proxyObject })
49
+ }
50
+ const getWorkSpaceUrl = () => {
51
+ switch (process.env.NODE_ENV_BLINQ) {
52
+ case 'local':
53
+ return 'http://localhost:6000/api/workspace'
54
+ case 'dev':
55
+ return 'https://dev.api.blinq.io/api/workspace'
56
+ case "stage":
57
+ return 'https://stage.api.blinq.io/api/workspace'
58
+ case 'prod':
59
+ return 'https://api.blinq.io/api/workspace'
60
+ case null:
61
+ return 'https://api.blinq.io/api/workspace'
62
+ default:
63
+ return `${process.env.NODE_ENV_BLINQ}/api/workspace`
64
+ }
65
+ }
66
+
67
+ for (let i = 2; i < argv.length; i++) {
68
+ const arg = argv[i]
69
+ switch (arg) {
70
+ case '--token':
71
+ if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
72
+ token = argv[++i]
73
+ } else {
74
+ console.error('Error: --token argument provided without a token.')
75
+ process.exit(1)
76
+ }
77
+ break
78
+ case '--extractDir':
79
+ if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
80
+ extractPath = argv[++i]
81
+ } else {
82
+ console.error('Error: --extractPath argument provided without a path.')
83
+ process.exit(1)
84
+ }
85
+ break
86
+ default:
87
+ console.error(`Unexpected argument: ${arg}`)
88
+ process.exit(1)
89
+ }
90
+ }
91
+
92
+ if (token === null || token === undefined || token === '') {
93
+ console.error('Error: --token argument not provided')
94
+ process.exit(1)
95
+ }
96
+ if (extractPath === '' || extractPath === null || extractPath === undefined) {
97
+ console.error('Error: --extractPath argument not provided')
98
+ process.exit(1)
99
+ }
100
+ const dirExists = (path) => {
101
+ try {
102
+ return fs.statSync(path).isDirectory()
103
+ } catch (e) {
104
+ if (e.code == 'ENOENT') {
105
+ // no such file or directory. File really does not exist
106
+ console.log('Not a valid directory: ' + path)
107
+ return false
108
+ }
109
+
110
+ console.log('Exception fs.statSync (' + path + '): ' + e)
111
+ throw e // something else went wrong, we don't have rights, ...
112
+ }
113
+ }
114
+ const ssoUrl = getSSoUrl()
115
+
116
+ const getProjectByAccessKey = async (access_key) => {
117
+ const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`
118
+ const response = await axios.post(accessKeyUrl, {
119
+ access_key,
120
+ httpAgent: getProxy(),
121
+ proxy: false,
122
+ })
123
+ if (response.status !== 200) {
124
+ console.error('Error: Invalid access key')
125
+ process.exit(1)
126
+ }
127
+ return response.data
128
+ };
129
+
130
+ const downloadAndInstall = async (extractPath, token) => {
131
+ if (!dirExists(extractPath)) {
132
+ fs.mkdirSync(extractPath, { recursive: true })
133
+ }
134
+ try {
135
+ const data = await getProjectByAccessKey(token)
136
+
137
+ const workspaceUrl = getWorkSpaceUrl() + '/pull-workspace'
138
+ const res = await axios.get(workspaceUrl, {
139
+ params: {
140
+ projectId: data.project._id,
141
+ },
142
+ httpAgent: getProxy(),
143
+ proxy: false,
144
+ responseType: 'arraybuffer',
145
+ headers: {
146
+ Authorization: `Bearer ${token}`,
147
+ 'Response-Type': 'arraybuffer',
148
+ },
149
+ })
150
+
151
+ if (res.status !== 200) {
152
+ console.error('Error: Unable to fetch workspace')
153
+ process.exit(1)
154
+ }
155
+
156
+ const zip = await JSZip.loadAsync(res.data)
157
+ for (const filename of Object.keys(zip.files)) {
158
+ const fileData = zip.files[filename]
159
+ if (!fileData.dir) {
160
+ const content = await fileData.async('nodebuffer')
161
+ const filePath = path.join(extractPath, filename)
162
+ mkdirSync(path.dirname(filePath), { recursive: true })
163
+ writeFileSync(filePath, content)
164
+ }
165
+ }
166
+
167
+ console.log('Extraction completed to:', extractPath)
168
+ } catch (error) {
169
+ console.error('Error:', error)
170
+ }
171
+ }
172
+
173
+ downloadAndInstall(extractPath, token).then(() =>
174
+ console.log('Download completed!')
175
+ )
@@ -27,6 +27,7 @@ async function convertConfiguration(flatConfiguration, env) {
27
27
  worldParameters: flatConfiguration.worldParameters,
28
28
  },
29
29
  formats: convertFormats(flatConfiguration, env),
30
+ runName: flatConfiguration.runName,
30
31
  };
31
32
  }
32
33
  exports.convertConfiguration = convertConfiguration;
@@ -1 +1 @@
1
- {"version":3,"file":"convert_configuration.js","sourceRoot":"","sources":["../../src/api/convert_configuration.ts"],"names":[],"mappings":";;;AAAA,oDAIyB;AAIlB,KAAK,UAAU,oBAAoB,CACxC,iBAAiC,EACjC,GAAsB;IAEtB,OAAO;QACL,OAAO,EAAE;YACP,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,cAAc,EAAE,iBAAiB,CAAC,QAAQ;YAC1C,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,aAAa,EAAE,iBAAiB,CAAC,IAAI;YACrC,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B;QACD,OAAO,EAAE;YACP,cAAc,EAAE,iBAAiB,CAAC,aAAa;YAC/C,YAAY,EAAE,iBAAiB,CAAC,OAAO;YACvC,WAAW,EAAE,iBAAiB,CAAC,MAAM;SACtC;QACD,OAAO,EAAE;YACP,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,iBAAiB,EAAE,CAAC,iBAAiB,CAAC,SAAS;YAC/C,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,KA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D,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,oBAAoB;QAC7B,KAAK,EAAE,GAAG,CAAC,sBAAsB;KAClC,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CACnB,iBAAiC,EACjC,GAAsB;IAEtB,OAAO,CACL,iBAAiB,CAAC,OAAO;QACzB,IAAA,8BAAc,EAAC,GAAG,CAAC,wBAAwB,CAAC;QAC5C,GAAG,CAAC,sBAAsB,KAAK,SAAS,CACzC,CAAA;AACH,CAAC","sourcesContent":["import {\n IConfiguration,\n isTruthyString,\n OptionSplitter,\n} from '../configuration'\nimport { IPublishConfig } from '../formatter'\nimport { IRunConfiguration } from './types'\n\nexport async function convertConfiguration(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): Promise<IRunConfiguration> {\n return {\n sources: {\n paths: flatConfiguration.paths,\n defaultDialect: flatConfiguration.language,\n names: flatConfiguration.name,\n tagExpression: flatConfiguration.tags,\n order: flatConfiguration.order,\n },\n support: {\n requireModules: flatConfiguration.requireModule,\n requirePaths: flatConfiguration.require,\n importPaths: flatConfiguration.import,\n },\n runtime: {\n dryRun: flatConfiguration.dryRun,\n failFast: flatConfiguration.failFast,\n filterStacktraces: !flatConfiguration.backtrace,\n parallel: flatConfiguration.parallel,\n retry: flatConfiguration.retry,\n retryTagFilter: flatConfiguration.retryTagFilter,\n strict: flatConfiguration.strict,\n worldParameters: flatConfiguration.worldParameters,\n },\n formats: convertFormats(flatConfiguration, env),\n }\n}\n\nfunction convertFormats(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n) {\n const splitFormats: string[][] = flatConfiguration.format.map((item) =>\n OptionSplitter.split(item)\n )\n return {\n stdout:\n [...splitFormats].reverse().find(([, target]) => !target)?.[0] ??\n 'progress',\n files: splitFormats\n .filter(([, target]) => !!target)\n .reduce((mapped, [type, target]) => {\n return {\n ...mapped,\n [target]: type,\n }\n }, {}),\n publish: makePublishConfig(flatConfiguration, env),\n options: flatConfiguration.formatOptions,\n }\n}\n\nfunction makePublishConfig(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): IPublishConfig | false {\n const enabled = isPublishing(flatConfiguration, env)\n if (!enabled) {\n return false\n }\n return {\n url: env.CUCUMBER_PUBLISH_URL,\n token: env.CUCUMBER_PUBLISH_TOKEN,\n }\n}\n\nfunction isPublishing(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): boolean {\n return (\n flatConfiguration.publish ||\n isTruthyString(env.CUCUMBER_PUBLISH_ENABLED) ||\n env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n}\n"]}
1
+ {"version":3,"file":"convert_configuration.js","sourceRoot":"","sources":["../../src/api/convert_configuration.ts"],"names":[],"mappings":";;;AAAA,oDAIyB;AAIlB,KAAK,UAAU,oBAAoB,CACxC,iBAAiC,EACjC,GAAsB;IAEtB,OAAO;QACL,OAAO,EAAE;YACP,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,cAAc,EAAE,iBAAiB,CAAC,QAAQ;YAC1C,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,aAAa,EAAE,iBAAiB,CAAC,IAAI;YACrC,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B;QACD,OAAO,EAAE;YACP,cAAc,EAAE,iBAAiB,CAAC,aAAa;YAC/C,YAAY,EAAE,iBAAiB,CAAC,OAAO;YACvC,WAAW,EAAE,iBAAiB,CAAC,MAAM;SACtC;QACD,OAAO,EAAE;YACP,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,iBAAiB,EAAE,CAAC,iBAAiB,CAAC,SAAS;YAC/C,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,cAAc,EAAE,iBAAiB,CAAC,cAAc;YAChD,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,eAAe,EAAE,iBAAiB,CAA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ACH,CAAC;AAED,SAAS,YAAY,CACnB,iBAAiC,EACjC,GAAsB;IAEtB,OAAO,CACL,iBAAiB,CAAC,OAAO;QACzB,IAAA,8BAAc,EAAC,GAAG,CAAC,wBAAwB,CAAC;QAC5C,GAAG,CAAC,sBAAsB,KAAK,SAAS,CACzC,CAAA;AACH,CAAC","sourcesContent":["import {\n IConfiguration,\n isTruthyString,\n OptionSplitter,\n} from '../configuration'\nimport { IPublishConfig } from '../formatter'\nimport { IRunConfiguration } from './types'\n\nexport async function convertConfiguration(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): Promise<IRunConfiguration> {\n return {\n sources: {\n paths: flatConfiguration.paths,\n defaultDialect: flatConfiguration.language,\n names: flatConfiguration.name,\n tagExpression: flatConfiguration.tags,\n order: flatConfiguration.order,\n },\n support: {\n requireModules: flatConfiguration.requireModule,\n requirePaths: flatConfiguration.require,\n importPaths: flatConfiguration.import,\n },\n runtime: {\n dryRun: flatConfiguration.dryRun,\n failFast: flatConfiguration.failFast,\n filterStacktraces: !flatConfiguration.backtrace,\n parallel: flatConfiguration.parallel,\n retry: flatConfiguration.retry,\n retryTagFilter: flatConfiguration.retryTagFilter,\n strict: flatConfiguration.strict,\n worldParameters: flatConfiguration.worldParameters,\n },\n formats: convertFormats(flatConfiguration, env),\n runName: flatConfiguration.runName,\n }\n}\n\nfunction convertFormats(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n) {\n const splitFormats: string[][] = flatConfiguration.format.map((item) =>\n OptionSplitter.split(item)\n )\n return {\n stdout:\n [...splitFormats].reverse().find(([, target]) => !target)?.[0] ??\n 'progress',\n files: splitFormats\n .filter(([, target]) => !!target)\n .reduce((mapped, [type, target]) => {\n return {\n ...mapped,\n [target]: type,\n }\n }, {}),\n publish: makePublishConfig(flatConfiguration, env),\n options: flatConfiguration.formatOptions,\n }\n}\n\nfunction makePublishConfig(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): IPublishConfig | false {\n const enabled = isPublishing(flatConfiguration, env)\n if (!enabled) {\n return false\n }\n return {\n url: env.CUCUMBER_PUBLISH_URL,\n token: env.CUCUMBER_PUBLISH_TOKEN,\n }\n}\n\nfunction isPublishing(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): boolean {\n return (\n flatConfiguration.publish ||\n isTruthyString(env.CUCUMBER_PUBLISH_ENABLED) ||\n env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n}\n"]}
@@ -8,14 +8,95 @@ const gherkin_streams_1 = require("@cucumber/gherkin-streams");
8
8
  const gherkin_utils_1 = require("@cucumber/gherkin-utils");
9
9
  const pickle_filter_1 = __importDefault(require("../pickle_filter"));
10
10
  const helpers_1 = require("../cli/helpers");
11
+ const feature_data_format_1 = require("../formatter/feature_data_format");
12
+ const node_path_1 = __importDefault(require("node:path"));
11
13
  async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeaturePaths, featurePaths, coordinates, onEnvelope, }) {
12
14
  const gherkinQuery = new gherkin_utils_1.Query();
13
15
  const parseErrors = [];
16
+ let variables, fakeData, pickleIndex = 0;
17
+ let dataFunction = null;
18
+ let functionVars = null;
19
+ let mjsDataFiles = null;
20
+ let projectDir = process.cwd();
21
+ if (featurePaths.length > 0) {
22
+ projectDir = node_path_1.default.join(node_path_1.default.dirname(featurePaths[0]), '..', '..');
23
+ }
14
24
  await gherkinFromPaths(featurePaths, {
15
25
  newId,
16
26
  relativeTo: cwd,
17
27
  defaultDialect: coordinates.defaultDialect,
18
28
  }, (envelope) => {
29
+ if (envelope.source) {
30
+ let newDataAfterExamplesModify = envelope.source.data;
31
+ const functionMatch = envelope.source.data.match(/@data:function:(.*?)\.(.*)/);
32
+ if (functionMatch) {
33
+ dataFunction = functionMatch[2];
34
+ const { newData, mjsData } = (0, feature_data_format_1.generateExamplesFromFunction)(envelope.source.data, featurePaths[0], dataFunction, functionMatch[1]);
35
+ newDataAfterExamplesModify = newData;
36
+ mjsDataFiles = mjsData;
37
+ }
38
+ const data = (0, feature_data_format_1.generateTestData)(newDataAfterExamplesModify, undefined, undefined, projectDir);
39
+ envelope.source.data = data.newContent;
40
+ variables = data.variables;
41
+ fakeData = data.otherFakeData;
42
+ }
43
+ if (envelope.gherkinDocument && envelope.gherkinDocument.feature) {
44
+ envelope.gherkinDocument.feature.children =
45
+ envelope.gherkinDocument.feature.children.map((scenario) => {
46
+ if (scenario.scenario) {
47
+ if (dataFunction) {
48
+ const { tableHeader, tableBody } = scenario.scenario.examples[0];
49
+ functionVars = {
50
+ previous: tableHeader.cells.map((cell, index) => ({
51
+ header: cell.value,
52
+ value: tableBody[0].cells[index].value,
53
+ })),
54
+ new: [],
55
+ };
56
+ const generateResult = (0, feature_data_format_1.generateExamplesFromFunctionGherkin)(tableHeader.cells, tableBody[0].cells, mjsDataFiles);
57
+ functionVars.new = generateResult;
58
+ generateResult.map(({ value }, index) => (scenario.scenario.examples[0].tableBody[0].cells[index].value = value));
59
+ }
60
+ let fakeDataIdx = 0;
61
+ scenario.scenario.examples.forEach((example) => {
62
+ example.tableBody.forEach((row) => {
63
+ row.cells.forEach((cell, index) => {
64
+ if (fakeDataIdx < fakeData.length &&
65
+ fakeData[fakeDataIdx].var === cell.value) {
66
+ cell.value = fakeData[fakeDataIdx].fake;
67
+ fakeDataIdx++;
68
+ }
69
+ });
70
+ });
71
+ });
72
+ scenario.scenario.steps = scenario.scenario.steps.map((step) => {
73
+ step.text = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData).newContent;
74
+ return step;
75
+ });
76
+ }
77
+ return scenario;
78
+ });
79
+ }
80
+ if (envelope.pickle) {
81
+ envelope.pickle.steps = envelope.pickle.steps.map((step) => {
82
+ if (functionVars) {
83
+ functionVars.new.forEach(({ value }, index) => {
84
+ step.text = step.text.replace(functionVars.previous[index].value, value);
85
+ });
86
+ }
87
+ const generateData = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData);
88
+ step.text = generateData.newContent;
89
+ pickleIndex =
90
+ generateData.fakeIndex > pickleIndex
91
+ ? generateData.fakeIndex
92
+ : pickleIndex;
93
+ return step;
94
+ });
95
+ for (let i = 0; i < pickleIndex; i++) {
96
+ fakeData.shift();
97
+ }
98
+ pickleIndex = 0;
99
+ }
19
100
  gherkinQuery.update(envelope);
20
101
  if (envelope.parseError) {
21
102
  parseErrors.push(envelope.parseError);
@@ -1 +1 @@
1
- {"version":3,"file":"gherkin.js","sourceRoot":"","sources":["../../src/api/gherkin.ts"],"names":[],"mappings":";;;;;;AAAA,+DAGkC;AASlC,2DAA+D;AAC/D,qEAA2C;AAC3C,4CAA6C;AAUtC,KAAK,UAAU,2BAA2B,CAAC,EAChD,KAAK,EACL,GAAG,EACH,MAAM,EACN,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,UAAU,GASX;IAIC,MAAM,YAAY,GAAG,IAAI,qBAAY,EAAE,CAAA;IACvC,MAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,MAAM,gBAAgB,CACpB,YAAY,EACZ;QACE,KAAK;QACL,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,WAAW,CAAC,cAAc;KAC3C,EACD,CAAC,QAAQ,EAAE,EAAE;QACX,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC7B,IAAI,QAAQ,CAAC,UAAU,EAAE;YACvB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;SACtC;QACD,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,QAAQ,CAAC,CAAA;IACxB,CAAC,CACF,CAAA;IACD,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC;QACpC,GAAG;QACH,YAAY,EAAE,sBAAsB;QACpC,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,aAAa,EAAE,WAAW,CAAC,aAAa;KACzC,CAAC,CAAA;IACF,MAAM,eAAe,GAAyB,YAAY;SACvD,UAAU,EAAE;SACZ,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACj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,CAAC","sourcesContent":["import {\n GherkinStreams,\n IGherkinStreamOptions,\n} from '@cucumber/gherkin-streams'\nimport {\n Envelope,\n GherkinDocument,\n IdGenerator,\n Location,\n ParseError,\n Pickle,\n} from '@cucumber/messages'\nimport { Query as GherkinQuery } from '@cucumber/gherkin-utils'\nimport PickleFilter from '../pickle_filter'\nimport { orderPickles } from '../cli/helpers'\nimport { ISourcesCoordinates } from './types'\nimport { ILogger } from '../logger'\n\ninterface PickleWithDocument {\n gherkinDocument: GherkinDocument\n location: Location\n pickle: Pickle\n}\n\nexport async function getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates,\n onEnvelope,\n}: {\n newId: IdGenerator.NewId\n cwd: string\n logger: ILogger\n unexpandedFeaturePaths: string[]\n featurePaths: string[]\n coordinates: ISourcesCoordinates\n onEnvelope?: (envelope: Envelope) => void\n}): Promise<{\n filteredPickles: PickleWithDocument[]\n parseErrors: ParseError[]\n}> {\n const gherkinQuery = new GherkinQuery()\n const parseErrors: ParseError[] = []\n await gherkinFromPaths(\n featurePaths,\n {\n newId,\n relativeTo: cwd,\n defaultDialect: coordinates.defaultDialect,\n },\n (envelope) => {\n gherkinQuery.update(envelope)\n if (envelope.parseError) {\n parseErrors.push(envelope.parseError)\n }\n onEnvelope?.(envelope)\n }\n )\n const pickleFilter = new PickleFilter({\n cwd,\n featurePaths: unexpandedFeaturePaths,\n names: coordinates.names,\n tagExpression: coordinates.tagExpression,\n })\n const filteredPickles: PickleWithDocument[] = gherkinQuery\n .getPickles()\n .filter((pickle) => {\n const gherkinDocument = gherkinQuery\n .getGherkinDocuments()\n .find((doc) => doc.uri === pickle.uri)\n return pickleFilter.matches({ gherkinDocument, pickle })\n })\n .map((pickle) => {\n const gherkinDocument = gherkinQuery\n .getGherkinDocuments()\n .find((doc) => doc.uri === pickle.uri)\n const location = gherkinQuery.getLocation(\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n )\n return {\n gherkinDocument,\n location,\n pickle,\n }\n })\n orderPickles(filteredPickles, coordinates.order, logger)\n return {\n filteredPickles,\n parseErrors,\n }\n}\n\nasync function gherkinFromPaths(\n paths: string[],\n options: IGherkinStreamOptions,\n onEnvelope: (envelope: Envelope) => void\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const gherkinMessageStream = GherkinStreams.fromPaths(paths, options)\n gherkinMessageStream.on('data', onEnvelope)\n gherkinMessageStream.on('end', resolve)\n gherkinMessageStream.on('error', reject)\n })\n}\n"]}
1
+ {"version":3,"file":"gherkin.js","sourceRoot":"","sources":["../../src/api/gherkin.ts"],"names":[],"mappings":";;;;;;AAAA,+DAGkC;AASlC,2DAA+D;AAC/D,qEAA2C;AAC3C,4CAA6C;AAG7C,0EAIyC;AACzC,0DAA4B;AAkBrB,KAAK,UAAU,2BAA2B,CAAC,EAChD,KAAK,EACL,GAAG,EACH,MAAM,EACN,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,UAAU,GASX;IAIC,MAAM,YAAY,GAAG,IAAI,qBAAY,EAAE,CAAA;IACvC,MAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,IAAI,SAAc,EAChB,QAGG,EACH,WAAW,GAAG,CAAC,CAAA;IACjB,IAAI,YAAY,GAAkB,IAAI,CAAA;IACtC,IAAI,YAAY,GAAwB,IAAI,CAAA;IAC5C,IAAI,YAAY,GAAQ,IAAI,CAAA;IAC5B,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC9B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;KAClE;IACD,MAAM,gBAAgB,CACpB,YAAY,EACZ;QACE,KAAK;QACL,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,WAAW,CAAC,cAAc;KAC3C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AAA,sBAAY,EAAC,eAAe,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACxD,OAAO;QACL,eAAe;QACf,WAAW;KACZ,CAAA;AACH,CAAC;AAjMD,kEAiMC;AAED,KAAK,UAAU,gBAAgB,CAC7B,KAAe,EACf,OAA8B,EAC9B,UAAwC;IAExC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,oBAAoB,GAAG,gCAAc,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACrE,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QAC3C,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACvC,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n GherkinStreams,\n IGherkinStreamOptions,\n} from '@cucumber/gherkin-streams'\nimport {\n Envelope,\n GherkinDocument,\n IdGenerator,\n Location,\n ParseError,\n Pickle,\n} from '@cucumber/messages'\nimport { Query as GherkinQuery } from '@cucumber/gherkin-utils'\nimport PickleFilter from '../pickle_filter'\nimport { orderPickles } from '../cli/helpers'\nimport { ISourcesCoordinates } from './types'\nimport { ILogger } from '../logger'\nimport {\n generateExamplesFromFunction,\n generateTestData,\n generateExamplesFromFunctionGherkin,\n} from '../formatter/feature_data_format'\nimport path from 'node:path'\ninterface PickleWithDocument {\n gherkinDocument: GherkinDocument\n location: Location\n pickle: Pickle\n}\n\ninterface FunctionVars {\n previous: {\n header: string\n value: any\n }[]\n new: {\n header: string\n value: any\n }[]\n}\n\nexport async function getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates,\n onEnvelope,\n}: {\n newId: IdGenerator.NewId\n cwd: string\n logger: ILogger\n unexpandedFeaturePaths: string[]\n featurePaths: string[]\n coordinates: ISourcesCoordinates\n onEnvelope?: (envelope: Envelope) => void\n}): Promise<{\n filteredPickles: PickleWithDocument[]\n parseErrors: ParseError[]\n}> {\n const gherkinQuery = new GherkinQuery()\n const parseErrors: ParseError[] = []\n let variables: any,\n fakeData: {\n var: string\n fake: string\n }[],\n pickleIndex = 0\n let dataFunction: string | null = null\n let functionVars: FunctionVars | null = null\n let mjsDataFiles: any = null\n let projectDir = process.cwd()\n if (featurePaths.length > 0) {\n projectDir = path.join(path.dirname(featurePaths[0]), '..', '..')\n }\n await gherkinFromPaths(\n featurePaths,\n {\n newId,\n relativeTo: cwd,\n defaultDialect: coordinates.defaultDialect,\n },\n (envelope) => {\n if (envelope.source) {\n let newDataAfterExamplesModify = envelope.source.data\n const functionMatch = envelope.source.data.match(\n /@data:function:(.*?)\\.(.*)/\n )\n\n if (functionMatch) {\n dataFunction = functionMatch[2]\n const { newData, mjsData } = generateExamplesFromFunction(\n envelope.source.data,\n featurePaths[0],\n dataFunction,\n functionMatch[1]\n )\n newDataAfterExamplesModify = newData\n mjsDataFiles = mjsData\n }\n\n const data = generateTestData(\n newDataAfterExamplesModify,\n undefined,\n undefined,\n projectDir\n )\n envelope.source.data = data.newContent\n variables = data.variables\n fakeData = data.otherFakeData\n }\n\n if (envelope.gherkinDocument && envelope.gherkinDocument.feature) {\n envelope.gherkinDocument.feature.children =\n envelope.gherkinDocument.feature.children.map((scenario) => {\n if (scenario.scenario) {\n if (dataFunction) {\n const { tableHeader, tableBody } = scenario.scenario.examples[0]\n\n functionVars = {\n previous: tableHeader.cells.map((cell, index) => ({\n header: cell.value,\n value: tableBody[0].cells[index].value,\n })),\n new: [],\n }\n\n const generateResult = generateExamplesFromFunctionGherkin(\n tableHeader.cells,\n tableBody[0].cells,\n mjsDataFiles\n )\n\n functionVars.new = generateResult\n\n generateResult.map(\n ({ value }, index) =>\n (scenario.scenario.examples[0].tableBody[0].cells[\n index\n ].value = value)\n )\n }\n let fakeDataIdx = 0\n scenario.scenario.examples.forEach((example) => {\n example.tableBody.forEach((row) => {\n row.cells.forEach((cell, index) => {\n if (\n fakeDataIdx < fakeData.length &&\n fakeData[fakeDataIdx].var === cell.value\n ) {\n cell.value = fakeData[fakeDataIdx].fake\n fakeDataIdx++\n }\n })\n })\n })\n scenario.scenario.steps = scenario.scenario.steps.map((step) => {\n step.text = generateTestData(\n step.text,\n variables,\n fakeData\n ).newContent\n return step\n })\n }\n return scenario\n })\n }\n\n if (envelope.pickle) {\n envelope.pickle.steps = envelope.pickle.steps.map((step) => {\n if (functionVars) {\n functionVars.new.forEach(({ value }, index) => {\n step.text = step.text.replace(\n functionVars.previous[index].value,\n value\n )\n })\n }\n const generateData = generateTestData(step.text, variables, fakeData)\n step.text = generateData.newContent\n pickleIndex =\n generateData.fakeIndex > pickleIndex\n ? generateData.fakeIndex\n : pickleIndex\n return step\n })\n\n for (let i = 0; i < pickleIndex; i++) {\n fakeData.shift()\n }\n pickleIndex = 0\n }\n\n gherkinQuery.update(envelope)\n if (envelope.parseError) {\n parseErrors.push(envelope.parseError)\n }\n onEnvelope?.(envelope)\n }\n )\n const pickleFilter = new PickleFilter({\n cwd,\n featurePaths: unexpandedFeaturePaths,\n names: coordinates.names,\n tagExpression: coordinates.tagExpression,\n })\n const filteredPickles: PickleWithDocument[] = gherkinQuery\n .getPickles()\n .filter((pickle) => {\n const gherkinDocument = gherkinQuery\n .getGherkinDocuments()\n .find((doc) => doc.uri === pickle.uri)\n return pickleFilter.matches({ gherkinDocument, pickle })\n })\n .map((pickle) => {\n const gherkinDocument = gherkinQuery\n .getGherkinDocuments()\n .find((doc) => doc.uri === pickle.uri)\n const location = gherkinQuery.getLocation(\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n )\n return {\n gherkinDocument,\n location,\n pickle,\n }\n })\n orderPickles(filteredPickles, coordinates.order, logger)\n return {\n filteredPickles,\n parseErrors,\n }\n}\n\nasync function gherkinFromPaths(\n paths: string[],\n options: IGherkinStreamOptions,\n onEnvelope: (envelope: Envelope) => void\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const gherkinMessageStream = GherkinStreams.fromPaths(paths, options)\n gherkinMessageStream.on('data', onEnvelope)\n gherkinMessageStream.on('end', resolve)\n gherkinMessageStream.on('error', reject)\n })\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Envelope } from '@cucumber/messages';
2
- import { IRunOptions, IRunEnvironment, IRunResult } from './types';
2
+ import { IRunEnvironment, IRunOptions, IRunResult } from './types';
3
3
  /**
4
4
  * Execute a Cucumber test run.
5
5
  *
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCucumber = void 0;
4
4
  const messages_1 = require("@cucumber/messages");
5
5
  const events_1 = require("events");
6
- const helpers_1 = require("../formatter/helpers");
7
- const helpers_2 = require("../cli/helpers");
8
- const paths_1 = require("./paths");
9
- const runtime_1 = require("./runtime");
10
- const formatters_1 = require("./formatters");
11
- const support_1 = require("./support");
6
+ const helpers_1 = require("../cli/helpers");
7
+ const helpers_2 = require("../formatter/helpers");
8
+ const console_logger_1 = require("./console_logger");
12
9
  const environment_1 = require("./environment");
10
+ const formatters_1 = require("./formatters");
13
11
  const gherkin_1 = require("./gherkin");
12
+ const paths_1 = require("./paths");
14
13
  const plugins_1 = require("./plugins");
15
- const console_logger_1 = require("./console_logger");
14
+ const runtime_1 = require("./runtime");
15
+ const support_1 = require("./support");
16
16
  /**
17
17
  * Execute a Cucumber test run.
18
18
  *
@@ -44,7 +44,7 @@ async function runCucumber(configuration, environment = {}, onMessage) {
44
44
  eventBroadcaster.on('envelope', onMessage);
45
45
  }
46
46
  eventBroadcaster.on('envelope', (value) => plugins.emit('message', value));
47
- const eventDataCollector = new helpers_1.EventDataCollector(eventBroadcaster);
47
+ const eventDataCollector = new helpers_2.EventDataCollector(eventBroadcaster);
48
48
  let formatterStreamError = false;
49
49
  const cleanupFormatters = await (0, formatters_1.initializeFormatters)({
50
50
  env,
@@ -58,7 +58,7 @@ async function runCucumber(configuration, environment = {}, onMessage) {
58
58
  configuration: configuration.formats,
59
59
  supportCodeLibrary,
60
60
  });
61
- await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
61
+ await (0, helpers_1.emitMetaMessage)(eventBroadcaster, env, configuration.runName);
62
62
  let pickleIds = [];
63
63
  let parseErrors = [];
64
64
  if (featurePaths.length > 0) {
@@ -85,7 +85,7 @@ async function runCucumber(configuration, environment = {}, onMessage) {
85
85
  support: supportCodeLibrary,
86
86
  };
87
87
  }
88
- (0, helpers_2.emitSupportCodeMessages)({
88
+ (0, helpers_1.emitSupportCodeMessages)({
89
89
  eventBroadcaster,
90
90
  supportCodeLibrary,
91
91
  newId,
@@ -1 +1 @@
1
- {"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,mCAAqC;AACrC,kDAAyD;AACzD,4CAAyE;AAEzE,mCAAsC;AACtC,uCAAuC;AACvC,6CAAmD;AACnD,uCAAiD;AACjD,+CAAgD;AAChD,uCAAuD;AACvD,uCAA6C;AAC7C,qDAAgD;AAGhD;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAC/B,aAA0B,EAC1B,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IACzE,MAAM,MAAM,GAAY,IAAI,8BAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAExD,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;IAEhC,MAAM,kBAAkB,GACtB,OAAO,IAAI,aAAa,CAAC,OAAO;QAC9B,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,mBAAmB;QAC3C,CAAC,CAAC,aAAa,CAAC,OAAO,CAAA;IAE3B,MAAM,EAAE,sBAAsB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AA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,iBAAiB,EAAE,CAAA;IACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IAEvB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA7GD,kCA6GC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { resolvePaths } from './paths'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { mergeEnvironment } from './environment'\nimport { getFilteredPicklesAndErrors } from './gherkin'\nimport { initializePlugins } from './plugins'\nimport { ConsoleLogger } from './console_logger'\nimport { ILogger } from '../logger'\n\n/**\n * Execute a Cucumber test run.\n *\n * @public\n * @param configuration - Configuration loaded from `loadConfiguration`.\n * @param environment - Project environment.\n * @param onMessage - Callback fired each time Cucumber emits a message.\n */\nexport async function runCucumber(\n configuration: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const { cwd, stdout, stderr, env, debug } = mergeEnvironment(environment)\n const logger: ILogger = new ConsoleLogger(stderr, debug)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'World' in configuration.support\n ? configuration.support.originalCoordinates\n : configuration.support\n\n const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } =\n await resolvePaths(logger, cwd, configuration.sources, supportCoordinates)\n\n const supportCodeLibrary =\n 'World' in configuration.support\n ? configuration.support\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const plugins = await initializePlugins(logger, configuration, environment)\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) => plugins.emit('message', value))\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (featurePaths.length > 0) {\n const gherkinResult = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates: configuration.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id)\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await plugins.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules: supportCoordinates.requireModules,\n requirePaths,\n importPaths,\n options: configuration.runtime,\n })\n const success = await runtime.start()\n await cleanupFormatters()\n await plugins.cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
1
+ {"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,mCAAqC;AACrC,4CAAyE;AACzE,kDAAyD;AAEzD,qDAAgD;A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,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,MAAM,CAAC,KAAK,CACV,mBAAmB,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC,OAAO,EAAE,CAClE,CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,iBAAiB,EAAE,CAAA;QACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACvB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC5B,CAAA;KACF;IAED,IAAA,iCAAuB,EAAC;QACtB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACN,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,GAAG;QACH,MAAM;QACN,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;QACT,KAAK;QACL,kBAAkB;QAClB,cAAc,EAAE,kBAAkB,CAAC,cAAc;QACjD,YAAY;QACZ,WAAW;QACX,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,iBAAiB,EAAE,CAAA;IACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IAEvB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA7GD,kCA6GC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ILogger } from '../logger'\nimport { ConsoleLogger } from './console_logger'\nimport { mergeEnvironment } from './environment'\nimport { initializeFormatters } from './formatters'\nimport { getFilteredPicklesAndErrors } from './gherkin'\nimport { resolvePaths } from './paths'\nimport { initializePlugins } from './plugins'\nimport { makeRuntime } from './runtime'\nimport { getSupportCodeLibrary } from './support'\nimport { IRunEnvironment, IRunOptions, IRunResult } from './types'\n\n/**\n * Execute a Cucumber test run.\n *\n * @public\n * @param configuration - Configuration loaded from `loadConfiguration`.\n * @param environment - Project environment.\n * @param onMessage - Callback fired each time Cucumber emits a message.\n */\nexport async function runCucumber(\n configuration: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const { cwd, stdout, stderr, env, debug } = mergeEnvironment(environment)\n const logger: ILogger = new ConsoleLogger(stderr, debug)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'World' in configuration.support\n ? configuration.support.originalCoordinates\n : configuration.support\n\n const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } =\n await resolvePaths(logger, cwd, configuration.sources, supportCoordinates)\n\n const supportCodeLibrary =\n 'World' in configuration.support\n ? configuration.support\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const plugins = await initializePlugins(logger, configuration, environment)\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) => plugins.emit('message', value))\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env, configuration.runName)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (featurePaths.length > 0) {\n const gherkinResult = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates: configuration.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id)\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await plugins.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules: supportCoordinates.requireModules,\n requirePaths,\n importPaths,\n options: configuration.runtime,\n })\n const success = await runtime.start()\n await cleanupFormatters()\n await plugins.cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { ISupportCodeLibrary } from '../support_code_library_builder/types';
3
+ import { Writable } from 'stream';
4
+ import { IConfiguration } from '../configuration';
4
5
  import { FormatOptions, IPublishConfig } from '../formatter';
5
6
  import { PickleOrder } from '../models/pickle_order';
6
7
  import { IRuntimeOptions } from '../runtime';
7
- import { IConfiguration } from '../configuration';
8
- import { Writable } from 'stream';
8
+ import { ISupportCodeLibrary } from '../support_code_library_builder/types';
9
9
  /**
10
10
  * @public
11
11
  */
@@ -113,6 +113,7 @@ export interface IRunConfiguration {
113
113
  support: ISupportCodeCoordinates;
114
114
  runtime: IRunOptionsRuntime;
115
115
  formats: IRunOptionsFormats;
116
+ runName?: string;
116
117
  }
117
118
  /**
118
119
  * @public
@@ -130,6 +131,7 @@ export interface IRunOptions {
130
131
  support: ISupportCodeCoordinatesOrLibrary;
131
132
  runtime: IRunOptionsRuntime;
132
133
  formats: IRunOptionsFormats;
134
+ runName?: string;
133
135
  }
134
136
  /**
135
137
  * Contextual data about the project environment.