@dev-blinq/cucumber-js 1.0.37 → 1.0.38-stage
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/bin/download-install.js +167 -0
- package/lib/api/convert_configuration.js +1 -0
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/gherkin.js +47 -1
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/run_cucumber.d.ts +1 -1
- package/lib/api/run_cucumber.js +10 -10
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/types.d.ts +5 -3
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +8 -6
- package/lib/cli/helpers.js +27 -6
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +7 -2
- package/lib/cli/index.js.map +1 -1
- package/lib/configuration/argv_parser.js +4 -2
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/configuration/axios_client.d.ts +1 -0
- package/lib/configuration/axios_client.js +40 -0
- package/lib/configuration/axios_client.js.map +1 -0
- package/lib/configuration/default_configuration.js +2 -0
- package/lib/configuration/default_configuration.js.map +1 -1
- package/lib/configuration/types.d.ts +2 -0
- package/lib/configuration/types.js.map +1 -1
- package/lib/formatter/api.d.ts +2 -0
- package/lib/formatter/api.js +53 -0
- package/lib/formatter/api.js.map +1 -0
- package/lib/formatter/bvt_analysis_formatter.d.ts +19 -0
- package/lib/formatter/bvt_analysis_formatter.js +244 -0
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
- package/lib/formatter/feature_data_format.d.ts +12 -3
- package/lib/formatter/feature_data_format.js +106 -8
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/formatters.js +2 -2
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/helpers/report_generator.d.ts +48 -8
- package/lib/formatter/helpers/report_generator.js +127 -4
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +6 -1
- package/lib/formatter/helpers/upload_serivce.js +142 -17
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +11 -0
- package/lib/formatter/helpers/uploader.js +140 -0
- package/lib/formatter/helpers/uploader.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +7 -2
- package/lib/formatter/bvt_formatter.d.ts +0 -9
- package/lib/formatter/bvt_formatter.js +0 -62
- package/lib/formatter/bvt_formatter.js.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
default:
|
|
23
|
+
return 'https://api.blinq.io/api/auth'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const getProxy = () => {
|
|
28
|
+
if (!process.env.PROXY) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const proxy = process.env.PROXY
|
|
33
|
+
const url = new URL(proxy)
|
|
34
|
+
const proxyObject = {
|
|
35
|
+
host: url.hostname,
|
|
36
|
+
port: Number(url.port),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { username, password } = url
|
|
40
|
+
|
|
41
|
+
if (username && password) {
|
|
42
|
+
proxyObject.proxyAuth = `${username}:${password}`
|
|
43
|
+
}
|
|
44
|
+
return tunnel.httpsOverHttp({ proxy: proxyObject })
|
|
45
|
+
}
|
|
46
|
+
const getWorkSpaceUrl = () => {
|
|
47
|
+
switch (process.env.NODE_ENV_BLINQ) {
|
|
48
|
+
case 'local':
|
|
49
|
+
return 'http://localhost:6000/api/workspace'
|
|
50
|
+
case 'dev':
|
|
51
|
+
return 'https://dev.api.blinq.io/api/workspace'
|
|
52
|
+
case "stage":
|
|
53
|
+
return 'https://stage.api.blinq.io/api/workspace'
|
|
54
|
+
default:
|
|
55
|
+
return 'https://api.blinq.io/api/workspace'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (let i = 2; i < argv.length; i++) {
|
|
60
|
+
const arg = argv[i]
|
|
61
|
+
switch (arg) {
|
|
62
|
+
case '--token':
|
|
63
|
+
if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
|
|
64
|
+
token = argv[++i]
|
|
65
|
+
} else {
|
|
66
|
+
console.error('Error: --token argument provided without a token.')
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
break
|
|
70
|
+
case '--extractDir':
|
|
71
|
+
if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
|
|
72
|
+
extractPath = argv[++i]
|
|
73
|
+
} else {
|
|
74
|
+
console.error('Error: --extractPath argument provided without a path.')
|
|
75
|
+
process.exit(1)
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
default:
|
|
79
|
+
console.error(`Unexpected argument: ${arg}`)
|
|
80
|
+
process.exit(1)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (token === null || token === undefined || token === '') {
|
|
85
|
+
console.error('Error: --token argument not provided')
|
|
86
|
+
process.exit(1)
|
|
87
|
+
}
|
|
88
|
+
if (extractPath === '' || extractPath === null || extractPath === undefined) {
|
|
89
|
+
console.error('Error: --extractPath argument not provided')
|
|
90
|
+
process.exit(1)
|
|
91
|
+
}
|
|
92
|
+
const dirExists = (path) => {
|
|
93
|
+
try {
|
|
94
|
+
return fs.statSync(path).isDirectory()
|
|
95
|
+
} catch (e) {
|
|
96
|
+
if (e.code == 'ENOENT') {
|
|
97
|
+
// no such file or directory. File really does not exist
|
|
98
|
+
console.log('Not a valid directory: ' + path)
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log('Exception fs.statSync (' + path + '): ' + e)
|
|
103
|
+
throw e // something else went wrong, we don't have rights, ...
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const ssoUrl = getSSoUrl()
|
|
107
|
+
|
|
108
|
+
const getProjectByAccessKey = async (access_key) => {
|
|
109
|
+
const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`
|
|
110
|
+
const response = await axios.post(accessKeyUrl, {
|
|
111
|
+
access_key,
|
|
112
|
+
httpAgent: getProxy(),
|
|
113
|
+
proxy: false,
|
|
114
|
+
})
|
|
115
|
+
if (response.status !== 200) {
|
|
116
|
+
console.error('Error: Invalid access key')
|
|
117
|
+
process.exit(1)
|
|
118
|
+
}
|
|
119
|
+
return response.data
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const downloadAndInstall = async (extractPath, token) => {
|
|
123
|
+
if (!dirExists(extractPath)) {
|
|
124
|
+
fs.mkdirSync(extractPath, { recursive: true })
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const data = await getProjectByAccessKey(token)
|
|
128
|
+
|
|
129
|
+
const workspaceUrl = getWorkSpaceUrl() + '/pull-workspace'
|
|
130
|
+
const res = await axios.get(workspaceUrl, {
|
|
131
|
+
params: {
|
|
132
|
+
projectId: data.project._id,
|
|
133
|
+
},
|
|
134
|
+
httpAgent: getProxy(),
|
|
135
|
+
proxy: false,
|
|
136
|
+
responseType: 'arraybuffer',
|
|
137
|
+
headers: {
|
|
138
|
+
Authorization: `Bearer ${token}`,
|
|
139
|
+
'Response-Type': 'arraybuffer',
|
|
140
|
+
},
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (res.status !== 200) {
|
|
144
|
+
console.error('Error: Unable to fetch workspace')
|
|
145
|
+
process.exit(1)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const zip = await JSZip.loadAsync(res.data)
|
|
149
|
+
for (const filename of Object.keys(zip.files)) {
|
|
150
|
+
const fileData = zip.files[filename]
|
|
151
|
+
if (!fileData.dir) {
|
|
152
|
+
const content = await fileData.async('nodebuffer')
|
|
153
|
+
const filePath = path.join(extractPath, filename)
|
|
154
|
+
mkdirSync(path.dirname(filePath), { recursive: true })
|
|
155
|
+
writeFileSync(filePath, content)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log('Extraction completed to:', extractPath)
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error('Error:', error)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
downloadAndInstall(extractPath, token).then(() =>
|
|
166
|
+
console.log('Download completed!')
|
|
167
|
+
)
|
|
@@ -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,EAA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B,CAAC,iBAAiB,EAAE,GAAG,CAAC;QAClD,OAAO,EAAE,iBAAiB,CAAC,aAAa;KACzC,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,iBAAiC,EACjC,GAAsB;IAEtB,MAAM,OAAO,GAAG,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,KAAK,CAAA;KACb;IACD,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 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"]}
|
package/lib/api/gherkin.js
CHANGED
|
@@ -9,17 +9,33 @@ 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
11
|
const feature_data_format_1 = require("../formatter/feature_data_format");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
13
|
async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeaturePaths, featurePaths, coordinates, onEnvelope, }) {
|
|
13
14
|
const gherkinQuery = new gherkin_utils_1.Query();
|
|
14
15
|
const parseErrors = [];
|
|
15
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
|
+
}
|
|
16
24
|
await gherkinFromPaths(featurePaths, {
|
|
17
25
|
newId,
|
|
18
26
|
relativeTo: cwd,
|
|
19
27
|
defaultDialect: coordinates.defaultDialect,
|
|
20
28
|
}, (envelope) => {
|
|
21
29
|
if (envelope.source) {
|
|
22
|
-
|
|
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);
|
|
23
39
|
envelope.source.data = data.newContent;
|
|
24
40
|
variables = data.variables;
|
|
25
41
|
fakeData = data.otherFakeData;
|
|
@@ -28,6 +44,31 @@ async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeatu
|
|
|
28
44
|
envelope.gherkinDocument.feature.children =
|
|
29
45
|
envelope.gherkinDocument.feature.children.map((scenario) => {
|
|
30
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
|
+
});
|
|
31
72
|
scenario.scenario.steps = scenario.scenario.steps.map((step) => {
|
|
32
73
|
step.text = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData).newContent;
|
|
33
74
|
return step;
|
|
@@ -38,6 +79,11 @@ async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeatu
|
|
|
38
79
|
}
|
|
39
80
|
if (envelope.pickle) {
|
|
40
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
|
+
}
|
|
41
87
|
const generateData = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData);
|
|
42
88
|
step.text = generateData.newContent;
|
|
43
89
|
pickleIndex =
|
package/lib/api/gherkin.js.map
CHANGED
|
@@ -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;AAG7C,0EAAmE;AAQ5D,KAAK,UAAU,2BAA2B,CAAC,EAChD,KAAK,EACL,GAAG,E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{\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 { generateTestData } from '../formatter/feature_data_format'\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 let variables: any,\n fakeData: {\n var: string\n fake: string\n }[],\n pickleIndex = 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 const data = generateTestData(envelope.source.data)\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 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 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
|
+
{"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,W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dGenerator,\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"]}
|
package/lib/api/run_cucumber.js
CHANGED
|
@@ -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("../
|
|
7
|
-
const helpers_2 = require("../
|
|
8
|
-
const
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
1
|
+
{"version":3,"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AAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACxE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAA;KACxC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE;QACtB,WAAW,CAAC,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"]}
|
package/lib/api/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
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 {
|
|
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.
|
package/lib/api/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'stream'\nimport { IConfiguration } from '../configuration'\nimport { FormatOptions, IPublishConfig } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\nimport { IRuntimeOptions } from '../runtime'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\n\n/**\n * @public\n */\nexport interface ILoadConfigurationOptions {\n /**\n * Path to load configuration file from (defaults to `cucumber.(js|cjs|mjs|json)` if omitted).\n */\n file?: string\n /**\n * Zero or more profile names from which to source configuration (if omitted or empty, the `default` profile will be used).\n */\n profiles?: string[]\n /**\n * Ad-hoc configuration options to be applied over the top of whatever is loaded from the configuration file/profiles.\n */\n provided?: Partial<IConfiguration>\n}\n\n/**\n * @public\n */\nexport interface IResolvedConfiguration {\n /**\n * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\n */\n useConfiguration: IConfiguration\n /**\n * The format that can be passed into `runCucumber`.\n */\n runConfiguration: IRunConfiguration\n}\n\n/**\n * @public\n */\nexport interface ISourcesCoordinates {\n defaultDialect: string\n paths: string[]\n names: string[]\n tagExpression: string\n order: PickleOrder\n}\n\n/**\n * @public\n */\nexport interface IPlannedPickle {\n name: string\n uri: string\n location: {\n line: number\n column?: number\n }\n}\n\n/**\n * @public\n */\nexport interface ISourcesError {\n uri: string\n location: {\n line: number\n column?: number\n }\n message: string\n}\n\n/**\n * @public\n */\nexport interface ILoadSourcesResult {\n plan: IPlannedPickle[]\n errors: ISourcesError[]\n}\n\n/**\n * @public\n */\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\n/**\n * @public\n */\nexport interface ILoadSupportOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsRuntime extends IRuntimeOptions {\n parallel: number\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsFormats {\n stdout: string\n files: Record<string, string>\n publish: IPublishConfig | false\n options: FormatOptions\n}\n\n/**\n * @public\n */\nexport interface IRunConfiguration {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n runName?: string\n}\n\n/**\n * @public\n */\nexport type ISupportCodeCoordinatesOrLibrary =\n | ISupportCodeCoordinates\n | ISupportCodeLibrary\n\n/**\n * @public\n */\nexport type { ISupportCodeLibrary }\n\n/**\n * @public\n */\nexport interface IRunOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinatesOrLibrary\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n runName?: string\n}\n\n/**\n * Contextual data about the project environment.\n *\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project (defaults to `process.cwd()` if omitted).\n */\n cwd?: string\n /**\n * Writable stream where the test run's main output is written (defaults to `process.stdout` if omitted).\n */\n stdout?: Writable\n /**\n * Writable stream where the test run's warning/error output is written (defaults to `process.stderr` if omitted).\n */\n stderr?: Writable\n /**\n * Environment variables (defaults to `process.env` if omitted).\n */\n env?: NodeJS.ProcessEnv\n /**\n * Whether debug logging is enabled.\n */\n debug?: boolean\n}\n\n/**\n * Result of a Cucumber test run.\n *\n * @public\n */\nexport interface IRunResult {\n /**\n * Whether the test run was overall successful i.e. no failed scenarios. The exact meaning can vary based on the `strict` configuration option.\n */\n success: boolean\n /**\n * The support code library that was used in the test run; can be reused in subsequent `runCucumber` calls.\n */\n support: ISupportCodeLibrary\n}\n"]}
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
5
|
import { EventEmitter } from 'events';
|
|
5
|
-
import PickleFilter from '../pickle_filter';
|
|
6
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
7
6
|
import { Readable } from 'stream';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { PickleOrder } from '../models/pickle_order';
|
|
7
|
+
import { IConfiguration } from '../configuration';
|
|
8
|
+
import { EventDataCollector } from '../formatter/helpers';
|
|
11
9
|
import { ILogger } from '../logger';
|
|
10
|
+
import { PickleOrder } from '../models/pickle_order';
|
|
11
|
+
import PickleFilter from '../pickle_filter';
|
|
12
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
12
13
|
interface IParseGherkinMessageStreamRequest {
|
|
13
14
|
cwd?: string;
|
|
14
15
|
eventBroadcaster: EventEmitter;
|
|
@@ -28,10 +29,11 @@ interface IParseGherkinMessageStreamRequest {
|
|
|
28
29
|
*/
|
|
29
30
|
export declare function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }: IParseGherkinMessageStreamRequest): Promise<string[]>;
|
|
30
31
|
export declare function orderPickles<T = string>(pickleIds: T[], order: PickleOrder, logger: ILogger): void;
|
|
31
|
-
export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv): Promise<void>;
|
|
32
|
+
export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv, runName?: string): Promise<void>;
|
|
32
33
|
export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
|
|
33
34
|
eventBroadcaster: EventEmitter;
|
|
34
35
|
supportCodeLibrary: ISupportCodeLibrary;
|
|
35
36
|
newId: IdGenerator.NewId;
|
|
36
37
|
}): void;
|
|
38
|
+
export declare function getRunName(argvConfiguration: Partial<IConfiguration>): string;
|
|
37
39
|
export {};
|
package/lib/cli/helpers.js
CHANGED
|
@@ -26,13 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles = exports.parseGherkinMessageStream = void 0;
|
|
29
|
+
exports.getRunName = exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles = exports.parseGherkinMessageStream = void 0;
|
|
30
|
+
const ci_environment_1 = __importDefault(require("@cucumber/ci-environment"));
|
|
31
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
30
32
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
31
|
-
const value_checker_1 = require("../value_checker");
|
|
32
|
-
const configuration_1 = require("../configuration");
|
|
33
33
|
const os_1 = __importDefault(require("os"));
|
|
34
|
-
const
|
|
35
|
-
const
|
|
34
|
+
const configuration_1 = require("../configuration");
|
|
35
|
+
const value_checker_1 = require("../value_checker");
|
|
36
36
|
const version_1 = require("../version");
|
|
37
37
|
/**
|
|
38
38
|
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
@@ -86,7 +86,7 @@ function orderPickles(pickleIds, order, logger) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.orderPickles = orderPickles;
|
|
89
|
-
async function emitMetaMessage(eventBroadcaster, env) {
|
|
89
|
+
async function emitMetaMessage(eventBroadcaster, env, runName) {
|
|
90
90
|
const meta = {
|
|
91
91
|
protocolVersion: messages.version,
|
|
92
92
|
implementation: {
|
|
@@ -105,6 +105,7 @@ async function emitMetaMessage(eventBroadcaster, env) {
|
|
|
105
105
|
version: process.versions.node,
|
|
106
106
|
},
|
|
107
107
|
ci: (0, ci_environment_1.default)(env),
|
|
108
|
+
runName,
|
|
108
109
|
};
|
|
109
110
|
eventBroadcaster.emit('envelope', {
|
|
110
111
|
meta,
|
|
@@ -200,4 +201,24 @@ function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId,
|
|
|
200
201
|
emitTestRunHooks(supportCodeLibrary, eventBroadcaster);
|
|
201
202
|
}
|
|
202
203
|
exports.emitSupportCodeMessages = emitSupportCodeMessages;
|
|
204
|
+
function getRunName(argvConfiguration) {
|
|
205
|
+
if ((0, value_checker_1.doesHaveValue)(argvConfiguration.runName)) {
|
|
206
|
+
return argvConfiguration.runName;
|
|
207
|
+
}
|
|
208
|
+
if ((0, value_checker_1.doesHaveValue)(argvConfiguration.name && argvConfiguration.name.length > 0)) {
|
|
209
|
+
return argvConfiguration.name[0];
|
|
210
|
+
}
|
|
211
|
+
if ((0, value_checker_1.doesHaveValue)(argvConfiguration.tags)) {
|
|
212
|
+
//replace word "and" with & and "or" with |
|
|
213
|
+
let tags = argvConfiguration.tags
|
|
214
|
+
.split(' ')
|
|
215
|
+
.map((tag) => (tag === 'and' ? '&' : tag === 'or' ? '|' : tag))
|
|
216
|
+
.join('');
|
|
217
|
+
//remove the starting and ending paranthesis if present
|
|
218
|
+
tags = tags.replace(/^\(/, '').replace(/\)$/, '');
|
|
219
|
+
return tags;
|
|
220
|
+
}
|
|
221
|
+
return '';
|
|
222
|
+
}
|
|
223
|
+
exports.getRunName = getRunName;
|
|
203
224
|
//# sourceMappingURL=helpers.js.map
|