vitest-cucumber-plugin 0.1.3 → 0.1.5

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/CONTRIBUTING.md CHANGED
@@ -36,7 +36,16 @@ branching model. The 'main' branch the release branch and is only pushed to dur
36
36
 
37
37
  ## Doing a release
38
38
 
39
- 1. git flow release start <version>
40
- 1. Update version number in package.json
41
- 1. Add the release notes to [RELEASE_NOTES.md](RELEASE_NOTES.md).
42
- 1. git flow release finish <version>
39
+ 1. ```$ VERSION=<version>```
40
+ 1. ```$ git flow release start v$VERSION```
41
+ 1. ```$ npm pkg set version=$VERSION```
42
+ 1. ```$ sed -i "1s/^/* v$VERSION : \!\!\! ADD RELEASE NOTE HERE \!\!\!\n/" RELEASE_NOTES.md```
43
+ 1. ```$ emacs -nw RELEASE_NOTES.md```
44
+ 2. ```$ npm test```
45
+ 1. ```$ git add . ; git commit -m v$VERSION```
46
+ 3. ```$ git flow release finish v$VERSION```
47
+ 4. ```$ git push```
48
+ 5. ```$ git checkout main```
49
+ 6. ```$ git push```
50
+ 7. ```$ git push origin v$VERSION```
51
+ 8. ```$ npm publish```
package/README.md CHANGED
@@ -5,7 +5,7 @@ Plugin for [Vitest](https://vitest.dev/) to allow tests to be written in [Cucumb
5
5
  ## Installation
6
6
 
7
7
  ```
8
- $ npm install --save-dev SamZiegler/vitest-cucumber-plugin
8
+ $ npm install --save-dev vitest-cucumber-plugin
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -109,5 +109,4 @@ work, but this configuration isn't tested.
109
109
  This plugin is not yet feature complete. Here is the list of features from Cucumber which aren't yet implemented:
110
110
  * Rule keyword
111
111
  * Doc strings
112
- * Data Table escape characters
113
112
  * Boolean expression support for tags
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,5 @@
1
+ * v0.1.5 : Implemented escape characters for Data Tables
2
+ * v0.1.4 : Changed README to point to RPM registry
1
3
  * v0.1.3 : Import modules from generated code to make sure they are processed correctly
2
4
  * v0.1.2 : Set default log level to warn and make it configurable
3
5
  * v0.1.1 : Use root dir from the config to find step_definitions dir
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-cucumber-plugin",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Plugin for Vitest which allows for tests to be written in Cucumber format.",
5
5
  "keywords": [
6
6
  "vite",
@@ -30,5 +30,5 @@
30
30
  "@types/lodash": "^4.14.194",
31
31
  "rollup": "^3.20.7"
32
32
  },
33
- "repository" : "https://github.com/SamZiegler/vitest-cucumber-plugin.git"
33
+ "repository": "https://github.com/SamZiegler/vitest-cucumber-plugin.git"
34
34
  }
package/src/gherkin.js CHANGED
@@ -40,9 +40,12 @@ const log = pino();
40
40
 
41
41
  log.level = 'warn';
42
42
 
43
+ const setLogLevel = (logLevel) => { log.level = logLevel; };
44
+
43
45
  var logger = /*#__PURE__*/Object.freeze({
44
46
  __proto__: null,
45
- log: log
47
+ log: log,
48
+ setLogLevel: setLogLevel
46
49
  });
47
50
 
48
51
  var require$$2 = /*@__PURE__*/getAugmentedNamespace(logger);
@@ -63,10 +66,12 @@ var require$$2 = /*@__PURE__*/getAugmentedNamespace(logger);
63
66
  colon : ':',
64
67
  step : '*',
65
68
  pipe : '|',
66
- backSlash : '\\',
69
+ escapedPipe : '\\|',
70
+ escapedNewline : '\\n',
71
+ escapedBackSlash : '\\\\',
67
72
  scenarioOutline : ['Scenario Outline','Scenario Template'],
68
73
  word : {
69
- match : /[^ \t\n:|\\]+/,
74
+ match : /[^ \t\n\:\|\@\*]+/,
70
75
  type : moo.keywords({
71
76
  feature : 'Feature',
72
77
  examples : ['Examples','Scenarios'],
@@ -127,7 +132,15 @@ var require$$2 = /*@__PURE__*/getAugmentedNamespace(logger);
127
132
  {"name": "dataTable", "symbols": ["dataTable", "dataTableRow"], "postprocess": data => fp.concat(data[0],[data[1]])},
128
133
  {"name": "dataTableRow", "symbols": ["_", (lexer.has("pipe") ? {type: "pipe"} : pipe), "dataTableColumns", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[2]},
129
134
  {"name": "dataTableColumns", "symbols": [], "postprocess": data => []},
130
- {"name": "dataTableColumns", "symbols": ["dataTableColumns", "text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => fp.concat(data[0],data[1].trim())},
135
+ {"name": "dataTableColumns", "symbols": ["dataTableColumns", "dataTableColumnText", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => fp.concat(data[0],data[1].trim())},
136
+ {"name": "dataTableColumnText", "symbols": [], "postprocess": data => ''},
137
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "escapedColumnCharaters"], "postprocess": data => data[0]+data[1]},
138
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "keywords"], "postprocess": data => data[0]+data[1]},
139
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
140
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
141
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
142
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
143
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
131
144
  {"name": "steps", "symbols": ["stepAndTable", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
132
145
  {"name": "moreSteps", "symbols": [], "postprocess": data => []},
133
146
  {"name": "moreSteps", "symbols": ["moreSteps", "stepAndTable"], "postprocess": data => fp.concat(data[0],data[1])},
@@ -138,12 +151,17 @@ var require$$2 = /*@__PURE__*/getAugmentedNamespace(logger);
138
151
  {"name": "text", "symbols": [], "postprocess": data => ''},
139
152
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
140
153
  {"name": "text", "symbols": ["text", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
141
- {"name": "text", "symbols": ["text", (lexer.has("step") ? {type: "step"} : step)], "postprocess": data => data[0]+data[1].value},
142
- {"name": "text", "symbols": ["text", (lexer.has("colon") ? {type: "colon"} : colon)], "postprocess": data => data[0]+data[1].value},
143
- {"name": "text", "symbols": ["text", (lexer.has("example") ? {type: "example"} : example)], "postprocess": data => data[0]+data[1].value},
144
- {"name": "text", "symbols": ["text", (lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0]+data[1].value},
145
- {"name": "text", "symbols": ["text", (lexer.has("scenarioOutline") ? {type: "scenarioOutline"} : scenarioOutline)], "postprocess": data => data[0]+data[1].value},
146
- {"name": "text", "symbols": ["text", (lexer.has("background") ? {type: "background"} : background)], "postprocess": data => data[0]+data[1].value},
154
+ {"name": "text", "symbols": ["text", "keywords"], "postprocess": data => data[0]+data[1]},
155
+ {"name": "text", "symbols": ["text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => data[0]+data[1].value},
156
+ {"name": "text", "symbols": ["text", (lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => data[0]+data[1].value},
157
+ {"name": "text", "symbols": ["text", (lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => data[0]+data[1].value},
158
+ {"name": "text", "symbols": ["text", (lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => data[0]+data[1].value},
159
+ {"name": "keywords", "symbols": [(lexer.has("step") ? {type: "step"} : step)], "postprocess": data => data[0].value},
160
+ {"name": "keywords", "symbols": [(lexer.has("colon") ? {type: "colon"} : colon)], "postprocess": data => data[0].value},
161
+ {"name": "keywords", "symbols": [(lexer.has("example") ? {type: "example"} : example)], "postprocess": data => data[0].value},
162
+ {"name": "keywords", "symbols": [(lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0].value},
163
+ {"name": "keywords", "symbols": [(lexer.has("scenarioOutline") ? {type: "scenarioOutline"} : scenarioOutline)], "postprocess": data => data[0].value},
164
+ {"name": "keywords", "symbols": [(lexer.has("background") ? {type: "background"} : background)], "postprocess": data => data[0].value},
147
165
  {"name": "bolText", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws), (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[1].value},
148
166
  {"name": "bolText", "symbols": [(lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0].value},
149
167
  {"name": "freeform", "symbols": [], "postprocess": data => ''},
package/src/gherkin.ne CHANGED
@@ -10,10 +10,12 @@ const lexer = moo.compile({
10
10
  colon : ':',
11
11
  step : '*',
12
12
  pipe : '|',
13
- backSlash : '\\',
13
+ escapedPipe : '\\|',
14
+ escapedNewline : '\\n',
15
+ escapedBackSlash : '\\\\',
14
16
  scenarioOutline : ['Scenario Outline','Scenario Template'],
15
17
  word : {
16
- match : /[^ \t\n:|\\]+/,
18
+ match : /[^ \t\n\:\|\@\*]+/,
17
19
  type : moo.keywords({
18
20
  feature : 'Feature',
19
21
  examples : ['Examples','Scenarios'],
@@ -90,7 +92,17 @@ dataTable -> null {% data => [] %}
90
92
  dataTableRow -> _ %pipe dataTableColumns %newline {% data => data[2] %}
91
93
 
92
94
  dataTableColumns -> null {% data => [] %}
93
- | dataTableColumns text %pipe {% data => fp.concat(data[0],data[1].trim()) %}
95
+ | dataTableColumns dataTableColumnText %pipe {% data => fp.concat(data[0],data[1].trim()) %}
96
+
97
+ dataTableColumnText -> null {% data => '' %}
98
+ | dataTableColumnText escapedColumnCharaters {% data => data[0]+data[1] %}
99
+ | dataTableColumnText keywords {% data => data[0]+data[1] %}
100
+ | dataTableColumnText %word {% data => data[0]+data[1].value %}
101
+ | dataTableColumnText %ws {% data => data[0]+data[1].value %}
102
+
103
+ escapedColumnCharaters -> %escapedPipe {% data => '|' %}
104
+ | %escapedBackSlash {% data => '\\' %}
105
+ | %escapedNewline {% data => '\n' %}
94
106
 
95
107
  steps -> stepAndTable moreSteps {% data => fp.concat(data[0],data[1]) %}
96
108
 
@@ -106,12 +118,18 @@ stepKeyword -> %step {% (data) => { return { type : 'step', name : data[0].value
106
118
  text -> null {% data => '' %}
107
119
  | text %word {% data => data[0]+data[1].value %}
108
120
  | text %ws {% data => data[0]+data[1].value %}
109
- | text %step {% data => data[0]+data[1].value %}
110
- | text %colon {% data => data[0]+data[1].value %}
111
- | text %example {% data => data[0]+data[1].value %}
112
- | text %examples {% data => data[0]+data[1].value %}
113
- | text %scenarioOutline {% data => data[0]+data[1].value %}
114
- | text %background {% data => data[0]+data[1].value %}
121
+ | text keywords {% data => data[0]+data[1] %}
122
+ | text %pipe {% data => data[0]+data[1].value %}
123
+ | text %escapedPipe {% data => data[0]+data[1].value %}
124
+ | text %escapedNewline {% data => data[0]+data[1].value %}
125
+ | text %escapedBackSlash {% data => data[0]+data[1].value %}
126
+
127
+ keywords -> %step {% data => data[0].value %}
128
+ | %colon {% data => data[0].value %}
129
+ | %example {% data => data[0].value %}
130
+ | %examples {% data => data[0].value %}
131
+ | %scenarioOutline {% data => data[0].value %}
132
+ | %background {% data => data[0].value %}
115
133
 
116
134
  bolText -> %ws %word {% data => data[1].value %}
117
135
  | %word {% data => data[0].value %}
@@ -14,10 +14,12 @@ const lexer = moo.compile({
14
14
  colon : ':',
15
15
  step : '*',
16
16
  pipe : '|',
17
- backSlash : '\\',
17
+ escapedPipe : '\\|',
18
+ escapedNewline : '\\n',
19
+ escapedBackSlash : '\\\\',
18
20
  scenarioOutline : ['Scenario Outline','Scenario Template'],
19
21
  word : {
20
- match : /[^ \t\n:|\\]+/,
22
+ match : /[^ \t\n\:\|\@\*]+/,
21
23
  type : moo.keywords({
22
24
  feature : 'Feature',
23
25
  examples : ['Examples','Scenarios'],
@@ -78,7 +80,15 @@ var grammar = {
78
80
  {"name": "dataTable", "symbols": ["dataTable", "dataTableRow"], "postprocess": data => fp.concat(data[0],[data[1]])},
79
81
  {"name": "dataTableRow", "symbols": ["_", (lexer.has("pipe") ? {type: "pipe"} : pipe), "dataTableColumns", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[2]},
80
82
  {"name": "dataTableColumns", "symbols": [], "postprocess": data => []},
81
- {"name": "dataTableColumns", "symbols": ["dataTableColumns", "text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => fp.concat(data[0],data[1].trim())},
83
+ {"name": "dataTableColumns", "symbols": ["dataTableColumns", "dataTableColumnText", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => fp.concat(data[0],data[1].trim())},
84
+ {"name": "dataTableColumnText", "symbols": [], "postprocess": data => ''},
85
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "escapedColumnCharaters"], "postprocess": data => data[0]+data[1]},
86
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "keywords"], "postprocess": data => data[0]+data[1]},
87
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
88
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
89
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
90
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
91
+ {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
82
92
  {"name": "steps", "symbols": ["stepAndTable", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
83
93
  {"name": "moreSteps", "symbols": [], "postprocess": data => []},
84
94
  {"name": "moreSteps", "symbols": ["moreSteps", "stepAndTable"], "postprocess": data => fp.concat(data[0],data[1])},
@@ -89,12 +99,17 @@ var grammar = {
89
99
  {"name": "text", "symbols": [], "postprocess": data => ''},
90
100
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
91
101
  {"name": "text", "symbols": ["text", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
92
- {"name": "text", "symbols": ["text", (lexer.has("step") ? {type: "step"} : step)], "postprocess": data => data[0]+data[1].value},
93
- {"name": "text", "symbols": ["text", (lexer.has("colon") ? {type: "colon"} : colon)], "postprocess": data => data[0]+data[1].value},
94
- {"name": "text", "symbols": ["text", (lexer.has("example") ? {type: "example"} : example)], "postprocess": data => data[0]+data[1].value},
95
- {"name": "text", "symbols": ["text", (lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0]+data[1].value},
96
- {"name": "text", "symbols": ["text", (lexer.has("scenarioOutline") ? {type: "scenarioOutline"} : scenarioOutline)], "postprocess": data => data[0]+data[1].value},
97
- {"name": "text", "symbols": ["text", (lexer.has("background") ? {type: "background"} : background)], "postprocess": data => data[0]+data[1].value},
102
+ {"name": "text", "symbols": ["text", "keywords"], "postprocess": data => data[0]+data[1]},
103
+ {"name": "text", "symbols": ["text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => data[0]+data[1].value},
104
+ {"name": "text", "symbols": ["text", (lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => data[0]+data[1].value},
105
+ {"name": "text", "symbols": ["text", (lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => data[0]+data[1].value},
106
+ {"name": "text", "symbols": ["text", (lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => data[0]+data[1].value},
107
+ {"name": "keywords", "symbols": [(lexer.has("step") ? {type: "step"} : step)], "postprocess": data => data[0].value},
108
+ {"name": "keywords", "symbols": [(lexer.has("colon") ? {type: "colon"} : colon)], "postprocess": data => data[0].value},
109
+ {"name": "keywords", "symbols": [(lexer.has("example") ? {type: "example"} : example)], "postprocess": data => data[0].value},
110
+ {"name": "keywords", "symbols": [(lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0].value},
111
+ {"name": "keywords", "symbols": [(lexer.has("scenarioOutline") ? {type: "scenarioOutline"} : scenarioOutline)], "postprocess": data => data[0].value},
112
+ {"name": "keywords", "symbols": [(lexer.has("background") ? {type: "background"} : background)], "postprocess": data => data[0].value},
98
113
  {"name": "bolText", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws), (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[1].value},
99
114
  {"name": "bolText", "symbols": [(lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0].value},
100
115
  {"name": "freeform", "symbols": [], "postprocess": data => ''},