pickle-jar 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# pickle-jar
|
|
2
|
-
|
|
2
|
+
pickle-jar is an alternative to jest-cucumber and and Cucumber.js that runs on top of jest. `pickle-jar`
|
|
3
|
+
allows defining test scnearios using Gherkin language and translates them into define/it blocks that run using jest.
|
|
4
|
+
Compared to jest-cucumber, the output is more explicit and all steps are reperesented by jest describe blocks.
|
|
3
5
|
|
|
6
|
+
[//]: <> (start placeholder for auto-badger)
|
|
4
7
|
|
|
5
8
|
[](https://npmjs.org/pickle-jar)
|
|
6
9
|
[](https://bundlephobia.com/result?p=pickle-jar)
|
|
@@ -9,20 +12,14 @@
|
|
|
9
12
|
|
|
10
13
|
[](https://libraries.io/npm/pickle-jar)
|
|
11
14
|
[](https://npmcharts.com/compare/pickle-jar)
|
|
12
|
-
[](https://github.com/nseba/pickle-jar/graphs/contributors)
|
|
13
|
-
[](https://github.com/nseba/pickle-jar/blob/master/CODE_OF_CONDUCT.md)
|
|
14
15
|
|
|
15
16
|
[](https://github.com/nseba/pickle-jar/stargazers)
|
|
16
17
|
[](https://github.com/nseba/pickle-jar/fork)
|
|
17
18
|
|
|
18
19
|
[//]: <> (end placeholder for auto-badger)
|
|
19
20
|
|
|
20
|
-
Framework for writing Gherkin features and running them using Jest
|
|
21
|
-
|
|
22
21
|
# Overview
|
|
23
|
-
|
|
24
|
-
allows defining test scnearios using Gherkin language and translates them into define/it blocks that run using jest.
|
|
25
|
-
Compared to jest-cucumber, the output is more explicit and all steps are reperesented by jest describe blocks.
|
|
22
|
+
|
|
26
23
|
|
|
27
24
|
The framework allows defining steps using regular expression matchers. Match groups are automatically passed as parameters
|
|
28
25
|
to the step function.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { StepDefinition } from "./step-definition";
|
|
2
2
|
import { WorldFactory } from "./world";
|
|
3
|
-
|
|
3
|
+
interface TestRunnerAllOptions {
|
|
4
|
+
workDir: string;
|
|
5
|
+
groupByFeaturePath: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type TestRunnerOptions = Partial<TestRunnerAllOptions>;
|
|
8
|
+
export declare function testRunner<TWorld>(globPattern: string, stepDefinitions: StepDefinition<TWorld>[], worldFactory: WorldFactory<TWorld>, tagFilter?: (tags: string[]) => boolean, options?: TestRunnerOptions): void;
|
|
9
|
+
export {};
|
package/dist/src/test-runner.js
CHANGED
|
@@ -40,26 +40,25 @@ const glob_1 = require("glob");
|
|
|
40
40
|
const os_1 = require("os");
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const feature_file_visitor_1 = require("./feature-file-visitor");
|
|
43
|
-
const get_call_sites_1 = require("./get-call-sites");
|
|
44
43
|
const GherkinLexer_1 = require("./grammar/GherkinLexer");
|
|
45
44
|
const GherkinParser_1 = require("./grammar/GherkinParser");
|
|
46
45
|
const jest_error_listener_1 = require("./jest-error-listener");
|
|
47
|
-
function testRunner(globPattern, stepDefinitions, worldFactory, tagFilter = () => true) {
|
|
48
|
-
|
|
46
|
+
function testRunner(globPattern, stepDefinitions, worldFactory, tagFilter = () => true, options) {
|
|
47
|
+
const defaultOptions = {
|
|
48
|
+
workDir: process.cwd(),
|
|
49
|
+
groupByFeaturePath: true,
|
|
50
|
+
};
|
|
51
|
+
const actualOptions = Object.assign(Object.assign({}, defaultOptions), options);
|
|
49
52
|
const featureFiles = glob_1.glob.sync(globPattern);
|
|
50
53
|
for (const featureFile of featureFiles) {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const dir = path.dirname(file);
|
|
54
|
-
const absoluteFeaturePath = path.resolve(dir, featureFile);
|
|
55
|
-
const relativeFeaturePath = path.relative(dir, absoluteFeaturePath);
|
|
54
|
+
const absoluteFeaturePath = path.resolve(actualOptions.workDir, featureFile);
|
|
55
|
+
const relativeFeaturePath = path.relative(actualOptions.workDir, absoluteFeaturePath);
|
|
56
56
|
const featureContext = {
|
|
57
|
-
|
|
58
|
-
directory: dir,
|
|
57
|
+
directory: actualOptions.workDir,
|
|
59
58
|
absoluteFeaturePath: absoluteFeaturePath,
|
|
60
59
|
relativeFeaturePath: relativeFeaturePath,
|
|
61
60
|
};
|
|
62
|
-
|
|
61
|
+
const run = () => {
|
|
63
62
|
const listener = new jest_error_listener_1.JestErrorListener();
|
|
64
63
|
const featureText = fs.readFileSync(absoluteFeaturePath, "utf-8") + os_1.EOL;
|
|
65
64
|
const input = antlr4ts_1.CharStreams.fromString(featureText);
|
|
@@ -74,7 +73,13 @@ function testRunner(globPattern, stepDefinitions, worldFactory, tagFilter = () =
|
|
|
74
73
|
const visitor = new feature_file_visitor_1.FeatureFileVisitor(worldFactory, stepDefinitions, tagFilter, featureContext);
|
|
75
74
|
parsedFeatureFile.accept(visitor);
|
|
76
75
|
listener.reportErrors();
|
|
77
|
-
}
|
|
76
|
+
};
|
|
77
|
+
if (actualOptions.groupByFeaturePath) {
|
|
78
|
+
describe(relativeFeaturePath, run);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
run();
|
|
82
|
+
}
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
//# sourceMappingURL=test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../../src/test-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../../src/test-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gCAiDC;AAtED,uCAA4D;AAC5D,uCAAyB;AACzB,+BAA4B;AAC5B,2BAAyB;AACzB,2CAA6B;AAG7B,iEAA4D;AAC5D,yDAAsD;AACtD,2DAA4E;AAC5E,+DAA0D;AAW1D,SAAgB,UAAU,CAA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