@dev-blinq/cucumber-js 1.0.2 → 1.0.4
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/README.md +40 -96
- package/lib/api/gherkin.js +13 -3
- package/lib/api/gherkin.js.map +1 -1
- package/lib/formatter/feature_data_format.d.ts +5 -1
- package/lib/formatter/feature_data_format.js +12 -7
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,124 +1,68 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="./docs/images/
|
|
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>
|
|
7
|
+
<b>Cucumber.js with Blinq.io adaptation</b>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
[
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[](https://coveralls.io/github/cucumber/cucumber-js?branch=master)
|
|
14
|
-
[](https://opencollective.com/cucumber)
|
|
15
|
-
[](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
|
-
|
|
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 @
|
|
19
|
+
$ npm install @dev-blinq/cucumber-js
|
|
32
20
|
```
|
|
33
21
|
|
|
34
22
|
## Get Started
|
|
35
23
|
|
|
36
|
-
|
|
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:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
82
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-

|
|
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
|
-
|
|
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.
|
package/lib/api/gherkin.js
CHANGED
|
@@ -12,7 +12,7 @@ const feature_data_format_1 = require("../formatter/feature_data_format");
|
|
|
12
12
|
async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeaturePaths, featurePaths, coordinates, onEnvelope, }) {
|
|
13
13
|
const gherkinQuery = new gherkin_utils_1.Query();
|
|
14
14
|
const parseErrors = [];
|
|
15
|
-
let variables;
|
|
15
|
+
let variables, fakeData, pickleIndex = 0;
|
|
16
16
|
await gherkinFromPaths(featurePaths, {
|
|
17
17
|
newId,
|
|
18
18
|
relativeTo: cwd,
|
|
@@ -22,13 +22,14 @@ async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeatu
|
|
|
22
22
|
const data = (0, feature_data_format_1.generateTestData)(envelope.source.data);
|
|
23
23
|
envelope.source.data = data.newContent;
|
|
24
24
|
variables = data.variables;
|
|
25
|
+
fakeData = data.otherFakeData;
|
|
25
26
|
}
|
|
26
27
|
if (envelope.gherkinDocument && envelope.gherkinDocument.feature) {
|
|
27
28
|
envelope.gherkinDocument.feature.children =
|
|
28
29
|
envelope.gherkinDocument.feature.children.map((scenario) => {
|
|
29
30
|
if (scenario.scenario) {
|
|
30
31
|
scenario.scenario.steps = scenario.scenario.steps.map((step) => {
|
|
31
|
-
step.text = (0, feature_data_format_1.generateTestData)(step.text, variables).newContent;
|
|
32
|
+
step.text = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData).newContent;
|
|
32
33
|
return step;
|
|
33
34
|
});
|
|
34
35
|
}
|
|
@@ -37,9 +38,18 @@ async function getFilteredPicklesAndErrors({ newId, cwd, logger, unexpandedFeatu
|
|
|
37
38
|
}
|
|
38
39
|
if (envelope.pickle) {
|
|
39
40
|
envelope.pickle.steps = envelope.pickle.steps.map((step) => {
|
|
40
|
-
|
|
41
|
+
const generateData = (0, feature_data_format_1.generateTestData)(step.text, variables, fakeData);
|
|
42
|
+
step.text = generateData.newContent;
|
|
43
|
+
pickleIndex =
|
|
44
|
+
generateData.fakeIndex > pickleIndex
|
|
45
|
+
? generateData.fakeIndex
|
|
46
|
+
: pickleIndex;
|
|
41
47
|
return step;
|
|
42
48
|
});
|
|
49
|
+
for (let i = 0; i < pickleIndex; i++) {
|
|
50
|
+
fakeData.shift();
|
|
51
|
+
}
|
|
52
|
+
pickleIndex = 0;
|
|
43
53
|
}
|
|
44
54
|
gherkinQuery.update(envelope);
|
|
45
55
|
if (envelope.parseError) {
|
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,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,CAAA;
|
|
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,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;IAEjB,MAAM,gBAAgB,CACpB,YAAY,EACZ;QACE,KAAK;QACL,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,WAAW,CAAC,cAAc;KAC3C,EACD,CAAC,QAAQ,EAAE,EAAE;QACX,IAAI,QAAQ,CAAC,MAAM,EAAE;YACnB,MAAM,IAAI,GAAG,IAAA,sCAAgB,EAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACnD,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAA;YACtC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;YAC1B,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AAC,eAAe,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACxD,OAAO;QACL,eAAe;QACf,WAAW;KACZ,CAAA;AACH,CAAC;AArHD,kEAqHC;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 { 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,4 +1,7 @@
|
|
|
1
|
-
declare const generateTestData: (featureFileContent: string, vars?: any
|
|
1
|
+
declare const generateTestData: (featureFileContent: string, vars?: any, fakeData?: {
|
|
2
|
+
var: string;
|
|
3
|
+
fake: string;
|
|
4
|
+
}[]) => {
|
|
2
5
|
newContent: string;
|
|
3
6
|
variables: any;
|
|
4
7
|
otherFakeData: {
|
|
@@ -6,5 +9,6 @@ declare const generateTestData: (featureFileContent: string, vars?: any) => {
|
|
|
6
9
|
fake: string;
|
|
7
10
|
}[];
|
|
8
11
|
changed: boolean;
|
|
12
|
+
fakeIndex: number;
|
|
9
13
|
};
|
|
10
14
|
export { generateTestData };
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTestData = void 0;
|
|
4
4
|
const faker_1 = require("@faker-js/faker");
|
|
5
|
-
const generateTestData = (featureFileContent, vars) => {
|
|
5
|
+
const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
6
6
|
const regexp = /\{\{([^}]+)\}\}/g;
|
|
7
|
+
const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g;
|
|
7
8
|
let newContent = featureFileContent;
|
|
8
9
|
let match;
|
|
9
10
|
const metches = [];
|
|
@@ -12,10 +13,8 @@ const generateTestData = (featureFileContent, vars) => {
|
|
|
12
13
|
metches.push(match);
|
|
13
14
|
}
|
|
14
15
|
// find all variables in the matches
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (vars) {
|
|
18
|
-
variables = vars;
|
|
16
|
+
const variables = { ...vars };
|
|
17
|
+
if (Object.keys(variables).length > 0) {
|
|
19
18
|
for (let i = 0; i < metches.length; i++) {
|
|
20
19
|
const _match = metches[i];
|
|
21
20
|
const value = _match[1];
|
|
@@ -51,14 +50,19 @@ const generateTestData = (featureFileContent, vars) => {
|
|
|
51
50
|
}
|
|
52
51
|
regexp.lastIndex = 0;
|
|
53
52
|
const otherFakeData = [];
|
|
54
|
-
|
|
53
|
+
const duplicateFakeData = fakeData ? [...fakeData] : [];
|
|
54
|
+
let fakeIndex = 0;
|
|
55
|
+
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
55
56
|
try {
|
|
56
|
-
const fake =
|
|
57
|
+
const fake = duplicateFakeData && duplicateFakeData.length > 0
|
|
58
|
+
? duplicateFakeData.shift().fake
|
|
59
|
+
: faker_1.faker.helpers.fake(match[0]);
|
|
57
60
|
otherFakeData.push({
|
|
58
61
|
var: match[0],
|
|
59
62
|
fake,
|
|
60
63
|
});
|
|
61
64
|
newContent = newContent.replace(match[0], fake);
|
|
65
|
+
fakeIndex++;
|
|
62
66
|
}
|
|
63
67
|
catch (err) {
|
|
64
68
|
// eslint-disable-next-line no-console
|
|
@@ -70,6 +74,7 @@ const generateTestData = (featureFileContent, vars) => {
|
|
|
70
74
|
variables,
|
|
71
75
|
otherFakeData,
|
|
72
76
|
changed: newContent !== featureFileContent,
|
|
77
|
+
fakeIndex,
|
|
73
78
|
};
|
|
74
79
|
};
|
|
75
80
|
exports.generateTestData = generateTestData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,MAAM,gBAAgB,GA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,CAAC,KAAK,IAAI,EAAE;QACzD,IAAI;YACF,MAAM,IAAI,GACR,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;gBAC/C,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,IAAI;gBAChC,CAAC,CAAC,aAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAClC,aAAa,CAAC,IAAI,CAAC;gBACjB,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;gBACb,IAAI;aACL,CAAC,CAAA;YACF,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;YAC/C,SAAS,EAAE,CAAA;SACZ;QAAC,OAAO,GAAG,EAAE;YACZ,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAClD;KACF;IAED,OAAO;QACL,UAAU;QACV,SAAS;QACT,aAAa;QACb,OAAO,EAAE,UAAU,KAAK,kBAAkB;QAC1C,SAAS;KACV,CAAA;AACH,CAAC,CAAA;AAIQ,4CAAgB","sourcesContent":["import { faker } from '@faker-js/faker'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[]\n) => {\n const regexp = /\\{\\{([^}]+)\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n const metches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n metches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < metches.length; i++) {\n const _match = metches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < metches.length; i++) {\n const _match = metches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = faker.helpers.fake(`{{${variable.toFake}}}`)\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n\n while ((match = regexp.exec(featureFileContent)) !== null) {\n try {\n const fake =\n duplicateFakeData && duplicateFakeData.length > 0\n ? duplicateFakeData.shift().fake\n : faker.helpers.fake(match[0])\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log('unknown faker variable:' + match[0])\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\n//let result = generateTestData(\"/Users/guyarieli/Documents/GitHub/ai-qa/cucumber_demo/features/create_issues.feature\");\n//console.log(result.newContent);\nexport { generateTestData }\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.4";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.4'\n"]}
|