pickle-jar 1.0.0 → 1.0.2

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.
@@ -1,176 +0,0 @@
1
- // Generated from ./src/grammar/GherkinParser.g4 by ANTLR 4.9.0-SNAPSHOT
2
-
3
-
4
- import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
5
-
6
- import { FeatureFileContext } from "./GherkinParser";
7
- import { FeatureContext } from "./GherkinParser";
8
- import { BackgroundContext } from "./GherkinParser";
9
- import { ScenarioContext } from "./GherkinParser";
10
- import { ScenarioOutlineContext } from "./GherkinParser";
11
- import { ExamplesBlockContext } from "./GherkinParser";
12
- import { TableHeaderContext } from "./GherkinParser";
13
- import { TableRowContext } from "./GherkinParser";
14
- import { CellContext } from "./GherkinParser";
15
- import { StepContext } from "./GherkinParser";
16
- import { GivenStepContext } from "./GherkinParser";
17
- import { AndGivenStepContext } from "./GherkinParser";
18
- import { WhenStepContext } from "./GherkinParser";
19
- import { AndWhenStepContext } from "./GherkinParser";
20
- import { ThenStepContext } from "./GherkinParser";
21
- import { AndStepContext } from "./GherkinParser";
22
- import { ButStepContext } from "./GherkinParser";
23
- import { DocStringContext } from "./GherkinParser";
24
- import { TagsContext } from "./GherkinParser";
25
- import { ContentTextContext } from "./GherkinParser";
26
-
27
-
28
- /**
29
- * This interface defines a complete generic visitor for a parse tree produced
30
- * by `GherkinParser`.
31
- *
32
- * @param <Result> The return type of the visit operation. Use `void` for
33
- * operations with no return type.
34
- */
35
- export interface GherkinParserVisitor<Result> extends ParseTreeVisitor<Result> {
36
- /**
37
- * Visit a parse tree produced by `GherkinParser.featureFile`.
38
- * @param ctx the parse tree
39
- * @return the visitor result
40
- */
41
- visitFeatureFile?: (ctx: FeatureFileContext) => Result;
42
-
43
- /**
44
- * Visit a parse tree produced by `GherkinParser.feature`.
45
- * @param ctx the parse tree
46
- * @return the visitor result
47
- */
48
- visitFeature?: (ctx: FeatureContext) => Result;
49
-
50
- /**
51
- * Visit a parse tree produced by `GherkinParser.background`.
52
- * @param ctx the parse tree
53
- * @return the visitor result
54
- */
55
- visitBackground?: (ctx: BackgroundContext) => Result;
56
-
57
- /**
58
- * Visit a parse tree produced by `GherkinParser.scenario`.
59
- * @param ctx the parse tree
60
- * @return the visitor result
61
- */
62
- visitScenario?: (ctx: ScenarioContext) => Result;
63
-
64
- /**
65
- * Visit a parse tree produced by `GherkinParser.scenarioOutline`.
66
- * @param ctx the parse tree
67
- * @return the visitor result
68
- */
69
- visitScenarioOutline?: (ctx: ScenarioOutlineContext) => Result;
70
-
71
- /**
72
- * Visit a parse tree produced by `GherkinParser.examplesBlock`.
73
- * @param ctx the parse tree
74
- * @return the visitor result
75
- */
76
- visitExamplesBlock?: (ctx: ExamplesBlockContext) => Result;
77
-
78
- /**
79
- * Visit a parse tree produced by `GherkinParser.tableHeader`.
80
- * @param ctx the parse tree
81
- * @return the visitor result
82
- */
83
- visitTableHeader?: (ctx: TableHeaderContext) => Result;
84
-
85
- /**
86
- * Visit a parse tree produced by `GherkinParser.tableRow`.
87
- * @param ctx the parse tree
88
- * @return the visitor result
89
- */
90
- visitTableRow?: (ctx: TableRowContext) => Result;
91
-
92
- /**
93
- * Visit a parse tree produced by `GherkinParser.cell`.
94
- * @param ctx the parse tree
95
- * @return the visitor result
96
- */
97
- visitCell?: (ctx: CellContext) => Result;
98
-
99
- /**
100
- * Visit a parse tree produced by `GherkinParser.step`.
101
- * @param ctx the parse tree
102
- * @return the visitor result
103
- */
104
- visitStep?: (ctx: StepContext) => Result;
105
-
106
- /**
107
- * Visit a parse tree produced by `GherkinParser.givenStep`.
108
- * @param ctx the parse tree
109
- * @return the visitor result
110
- */
111
- visitGivenStep?: (ctx: GivenStepContext) => Result;
112
-
113
- /**
114
- * Visit a parse tree produced by `GherkinParser.andGivenStep`.
115
- * @param ctx the parse tree
116
- * @return the visitor result
117
- */
118
- visitAndGivenStep?: (ctx: AndGivenStepContext) => Result;
119
-
120
- /**
121
- * Visit a parse tree produced by `GherkinParser.whenStep`.
122
- * @param ctx the parse tree
123
- * @return the visitor result
124
- */
125
- visitWhenStep?: (ctx: WhenStepContext) => Result;
126
-
127
- /**
128
- * Visit a parse tree produced by `GherkinParser.andWhenStep`.
129
- * @param ctx the parse tree
130
- * @return the visitor result
131
- */
132
- visitAndWhenStep?: (ctx: AndWhenStepContext) => Result;
133
-
134
- /**
135
- * Visit a parse tree produced by `GherkinParser.thenStep`.
136
- * @param ctx the parse tree
137
- * @return the visitor result
138
- */
139
- visitThenStep?: (ctx: ThenStepContext) => Result;
140
-
141
- /**
142
- * Visit a parse tree produced by `GherkinParser.andStep`.
143
- * @param ctx the parse tree
144
- * @return the visitor result
145
- */
146
- visitAndStep?: (ctx: AndStepContext) => Result;
147
-
148
- /**
149
- * Visit a parse tree produced by `GherkinParser.butStep`.
150
- * @param ctx the parse tree
151
- * @return the visitor result
152
- */
153
- visitButStep?: (ctx: ButStepContext) => Result;
154
-
155
- /**
156
- * Visit a parse tree produced by `GherkinParser.docString`.
157
- * @param ctx the parse tree
158
- * @return the visitor result
159
- */
160
- visitDocString?: (ctx: DocStringContext) => Result;
161
-
162
- /**
163
- * Visit a parse tree produced by `GherkinParser.tags`.
164
- * @param ctx the parse tree
165
- * @return the visitor result
166
- */
167
- visitTags?: (ctx: TagsContext) => Result;
168
-
169
- /**
170
- * Visit a parse tree produced by `GherkinParser.contentText`.
171
- * @param ctx the parse tree
172
- * @return the visitor result
173
- */
174
- visitContentText?: (ctx: ContentTextContext) => Result;
175
- }
176
-
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "noUnusedLocals": false,
6
- "noUnusedParameters": false
7
- },
8
- "include": []
9
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./test-runner";
2
- export * from "./step-definition";
3
- export * from "./step";
@@ -1,6 +0,0 @@
1
- import {Step} from "./step";
2
-
3
- export interface StepDefinition<TWorld> {
4
- match: RegExp,
5
- step: Step<TWorld>;
6
- }
package/src/step.ts DELETED
@@ -1 +0,0 @@
1
- export type Step<TWorld> = (world: TWorld,...params: string[]) => void;
@@ -1,34 +0,0 @@
1
- import {BufferedTokenStream, CharStreams} from "antlr4ts";
2
- import * as fs from "fs";
3
- import {glob} from "glob";
4
- import * as path from "path";
5
- import {FeatureFileVisitor} from "./feature-file-visitor";
6
- import {getCallSites} from "./get-call-sites";
7
- import {GherkinLexer} from "./grammar/GherkinLexer";
8
- import {GherkinParser} from "./grammar/GherkinParser";
9
- import {StepDefinition} from "./step-definition";
10
-
11
- export function testRunner<TWorld>(globPattern: string, stepDefinitions: StepDefinition<TWorld>[], world: TWorld) {
12
-
13
- const featureFiles = glob.sync(globPattern);
14
- for (const featureFile of featureFiles) {
15
- const callSite = getCallSites()[1];
16
- const file = callSite?.getFileName() ?? "";
17
- const dir = path.dirname(file);
18
- const absoluteFeaturePath = path.resolve(dir, featureFile);
19
-
20
- const featureText = fs.readFileSync(absoluteFeaturePath, "utf-8")
21
- const input = CharStreams.fromString(featureText);
22
- const lexer = new GherkinLexer(input);
23
-
24
- const lexerStream = new BufferedTokenStream(lexer);
25
- const parser = new GherkinParser(lexerStream);
26
-
27
- const parsedFeatureFile = parser.featureFile();
28
-
29
- const visitor = new FeatureFileVisitor<TWorld>(world, stepDefinitions);
30
- parsedFeatureFile.accept(visitor);
31
- }
32
-
33
-
34
- }
@@ -1,15 +0,0 @@
1
- Feature: Scenario outlines
2
-
3
- Scenario Outline: Using example values in steps
4
- Given a scenario outline named '<name>'
5
- When the outline parameter is '<parameter>'
6
- Then the world stores the '<name>' '<parameter>'
7
- And it can also be used as a docstring
8
- """
9
- <name> <parameter>
10
- """
11
-
12
- Examples:
13
- | name | parameter |
14
- | scenario name | parameter name |
15
- | another scenario name | another parameter name |
@@ -1,41 +0,0 @@
1
- Feature: Running scenarios
2
-
3
- Scenario: Simple scenario execution
4
- Given a simple text
5
- When running the test framework
6
- Then no error should be reported
7
-
8
- Scenario: Extracting arguments from the step
9
- Given the foo word
10
- When running the test framework
11
- Then the given argument should be 'foo'
12
-
13
- Scenario: Using arguments and doc string arguments
14
- Given the 'input.txt' file with contents:
15
- """
16
- contents
17
- """
18
- When running the test framework
19
- Then the 'input.txt' file should contain 'contents'
20
-
21
- Scenario: Using multiline docstrings
22
- Given the input string:
23
- """
24
- first line
25
- second line
26
- """
27
- When running the test framework
28
- Then the output string is:
29
- """
30
- first line
31
- second line
32
- """
33
-
34
- Scenario: Using multiple steps
35
- Given a first step
36
- And given a second step
37
- When running the test framework
38
- And when using two steps
39
- Then the first step ran
40
- And the second step ran
41
- But the third step didn't run
package/test/runner.ts DELETED
@@ -1,90 +0,0 @@
1
- import {StepDefinition, testRunner} from "../src";
2
-
3
- type World = Record<string, string>;
4
-
5
- const stepDefinitions: StepDefinition<World>[] = [{
6
- match: /^Given a simple text$/, step: (world) => {
7
- world['Simple text'];
8
- }
9
- }, {
10
- match: /^Given the (\w+) word$/, step: (world, word) => {
11
- world['given argument'] = word;
12
- }
13
- }, {
14
- match: /^Given the '([\w.]+)' file with contents:$/, step: (world, file, contents) => {
15
- world[file] = contents;
16
- }
17
- }, {
18
- match: /^Given the input string:$/, step: (world, input) => {
19
- world["input string"] = input;
20
- }
21
- }, {
22
- match: /^Given a first step$/, step: (world) => {
23
- world["first step"] = "true";
24
- }
25
- }, {
26
- match: /^Given a second step$/, step: (world) => {
27
- world["second step"] = "true";
28
- }
29
- }, {
30
- match: /^Given a scenario outline named '(.+)'$/, step: (world, name) => {
31
- world["outline-name"] = name;
32
- }
33
- }, {
34
- match: /^When running the test framework$/, step: world => {
35
- /*nop*/
36
- }
37
- }, {
38
- match: /^When using two steps/, step: world => {
39
- /*nop*/
40
- }
41
- }, {
42
- match: /^When the outline parameter is '(.+)'$/, step: (world, param) => {
43
- world["outline-param"] = param;
44
- }
45
- }, {
46
- match: /^Then no error should be reported$/, step: world => {
47
- /*nop*/
48
- }
49
- }, {
50
- match: /^Then the given argument should be '(.*)'$/, step: (world, arg) => {
51
- expect(world['given argument']).toBe(arg);
52
- }
53
- }, {
54
- match: /^Then the '([\w.]+)' file should contain '([^']+)'$/, step(world, file, contents) {
55
- expect(world[file]).not.toBeUndefined();
56
- expect(world[file]).toBe(contents);
57
- }
58
- }, {
59
- match: /^Then the output string is:$/, step: (world, text) => {
60
- expect(world['input string']).not.toBeUndefined();
61
- expect(world['input string']).toBe(text);
62
- }
63
- }, {
64
- match: /^Then the first step ran$/, step: world => {
65
- expect(world['first step']).toBe("true");
66
- }
67
- }, {
68
- match: /^Then the second step ran$/, step: world => {
69
- expect(world['second step']).toBe("true");
70
- }
71
- }, {
72
- match: /^Then the world stores the '([^']+)' '([^']+)'/, step: (world, name, parameter) => {
73
- expect(world['outline-name']).not.toBeUndefined();
74
- expect(world['outline-name']).toBe(name);
75
-
76
- expect(world['outline-param']).not.toBeUndefined();
77
- expect(world['outline-param']).toBe(parameter);
78
- }
79
- }, {
80
- match: /^Then it can also be used as a docstring$/, step: (world, docstring) => {
81
- expect(docstring).toBe(`${world['outline-name']} ${world['outline-param']}`)
82
- }
83
- }, {
84
- match: /^But the third step didn't run$/, step: world => {
85
- expect(world['third step']).toBeUndefined();
86
- }
87
- }]
88
-
89
-
90
- testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, {});
package/tsconfig.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": ".",
4
- "outDir": "dist",
5
- "module": "commonjs",
6
- "target": "es6",
7
- "sourceMap": true,
8
- "jsx": "react",
9
- "moduleResolution": "node",
10
- "rootDir": ".",
11
- "forceConsistentCasingInFileNames": true,
12
- "noImplicitReturns": true,
13
- "noImplicitThis": true,
14
- "noImplicitAny": true,
15
- "importHelpers": true,
16
- "strictNullChecks": true,
17
- "noUnusedLocals": true,
18
- "resolveJsonModule": true,
19
- "allowSyntheticDefaultImports": true,
20
- "alwaysStrict": true,
21
- "declaration": true,
22
- "declarationDir": "dist/types",
23
- "typeRoots": [
24
- "node_modules/@types"
25
- ],
26
- "esModuleInterop": true
27
- },
28
- "exclude": [
29
- "node_modules",
30
- "build",
31
- "scripts",
32
- "acceptance-tests",
33
- "webpack",
34
- "jest",
35
- "public",
36
- "secure",
37
- "bin",
38
- "dist",
39
- "docs",
40
- "coverage"
41
- ],
42
- "references": [{
43
- "path": "./src/grammar"
44
- }, {
45
- "path": "./tsconfig.spec.json"
46
- }]
47
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "outDir": "../../dist/out-tsc",
6
- "module": "commonjs",
7
- "types": ["jest", "node"]
8
- },
9
- "include": [
10
- "**/*.spec.ts",
11
- "**/*.d.ts",
12
- "test/**/*.ts"
13
- ]
14
- }
package/typedoc.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "plugin": [
3
- "typedoc-plugin-markdown"
4
- ],
5
- "excludeProtected": true,
6
- "excludeInternal": true,
7
- "excludePrivate": true
8
- }