vitest-cucumber-plugin 0.5.4 → 0.5.6

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/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,5 @@
1
+ * v0.5.6 : Fixed issue #25 which was preventing at symbols from being used in data tables
2
+ * v0.5.5 : Changed dynamic import statements to static ones so that Vitest watch works correctly
1
3
  * v0.5.4 : Added vue test
2
4
  * v0.5.3 : Provide code snippets when a step definition is not found
3
5
  * v0.5.2 : Throw an error if a step file import fails instead of logging it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-cucumber-plugin",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Plugin for Vitest which allows for tests to be written in Cucumber format.",
5
5
  "keywords": [
6
6
  "vite",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@cucumber/cucumber-expressions": "^16.1.2",
23
+ "glob": "^10.2.2",
23
24
  "lodash": "^4.17.21",
24
25
  "moo": "^0.5.2",
25
26
  "nearley": "^2.20.1",
@@ -2,8 +2,11 @@ import _ from 'lodash/fp.js';
2
2
  import { log } from '../logger.js';
3
3
  import { generateExample, generateScenarioOutline, generateRule } from './index.js';
4
4
  import { escape, shouldSkip } from './util.js';
5
+ import { glob } from 'glob';
5
6
 
6
- export const generateFeature = (config,feature) => {
7
+ const findJsFiles = async () => glob('features/**/*.js');
8
+
9
+ export const generateFeature = async (config,feature) => {
7
10
  const name = feature.name;
8
11
  const statements = feature.statements;
9
12
 
@@ -27,6 +30,14 @@ export const generateFeature = (config,feature) => {
27
30
  const configStr = JSON.stringify(config);
28
31
  const tagsStr = JSON.stringify(feature.tags);
29
32
 
33
+ const jsFilesImportReducer = (imports,file) => {
34
+ file = file.slice('features/'.length);
35
+ return imports+`
36
+ import './${file}';`;
37
+ };
38
+ const jsFiles = await findJsFiles();
39
+ const jsFilesImport = _.reduce(jsFilesImportReducer,'',jsFiles);
40
+
30
41
  const code = `import { expect, test, describe, beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
31
42
  import {
32
43
  Test,
@@ -38,36 +49,10 @@ import {
38
49
  applyAfterStepHooks,
39
50
  } from 'vitest-cucumber-plugin';
40
51
  import { readdir } from 'node:fs/promises';
41
- import { log, logConfig } from 'vitest-cucumber-plugin';
52
+ import { log, logConfig } from 'vitest-cucumber-plugin';${jsFilesImport}
42
53
 
43
54
  logConfig(${JSON.stringify(config.log)});
44
55
 
45
- const importDirectory = async (directory) => {
46
- log.debug('importDirectory directory: '+directory);
47
- try {
48
- const files = await readdir(directory);
49
-
50
- for (const file of files) {
51
- const filename = directory+'/'+file;
52
- log.debug('importDirectory import: '+filename);
53
- await import(filename);
54
- }
55
- } catch (e) {
56
- if (e.code === "ENOENT") {
57
- return;
58
- }
59
- throw e;
60
- }
61
- };
62
-
63
- const importSupportFiles = async (config) => importDirectory(config.root+'/features/support');
64
-
65
- await importSupportFiles(${configStr});
66
-
67
- const importStepDefinitions = async (config) => importDirectory(config.root+'/features/step_definitions');
68
-
69
- await importStepDefinitions(${configStr});
70
-
71
56
  var state = {};
72
57
 
73
58
  beforeAll(async () => {
package/src/gherkin.js CHANGED
@@ -126,6 +126,7 @@ var gherkin_umd$1 = {exports: {}};
126
126
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "keywords"], "postprocess": data => data[0]+data[1]},
127
127
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
128
128
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
129
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("at") ? {type: "at"} : at)], "postprocess": data => data[0]+data[1].value},
129
130
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
130
131
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
131
132
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
@@ -152,6 +153,7 @@ var gherkin_umd$1 = {exports: {}};
152
153
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
153
154
  {"name": "text", "symbols": ["text", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
154
155
  {"name": "text", "symbols": ["text", "keywords"], "postprocess": data => data[0]+data[1]},
156
+ {"name": "text", "symbols": ["text", (lexer.has("at") ? {type: "at"} : at)], "postprocess": data => data[0]+data[1].value},
155
157
  {"name": "text", "symbols": ["text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => data[0]+data[1].value},
156
158
  {"name": "text", "symbols": ["text", (lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => data[0]+data[1].value},
157
159
  {"name": "text", "symbols": ["text", (lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => data[0]+data[1].value},
package/src/gherkin.ne CHANGED
@@ -132,6 +132,7 @@ dataTableColumnText -> null {% data => '' %}
132
132
  | dataTableColumnText keywords {% data => data[0]+data[1] %}
133
133
  | dataTableColumnText %word {% data => data[0]+data[1].value %}
134
134
  | dataTableColumnText %ws {% data => data[0]+data[1].value %}
135
+ | dataTableColumnText %at {% data => data[0]+data[1].value %}
135
136
 
136
137
  escapedColumnCharaters -> %escapedPipe {% data => '|' %}
137
138
  | %escapedBackSlash {% data => '\\' %}
@@ -168,6 +169,7 @@ text -> null {% data => '' %}
168
169
  | text %word {% data => data[0]+data[1].value %}
169
170
  | text %ws {% data => data[0]+data[1].value %}
170
171
  | text keywords {% data => data[0]+data[1] %}
172
+ | text %at {% data => data[0]+data[1].value %}
171
173
  | text %pipe {% data => data[0]+data[1].value %}
172
174
  | text %escapedPipe {% data => data[0]+data[1].value %}
173
175
  | text %escapedNewline {% data => data[0]+data[1].value %}
@@ -117,6 +117,7 @@ var grammar = {
117
117
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", "keywords"], "postprocess": data => data[0]+data[1]},
118
118
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
119
119
  {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
120
+ {"name": "dataTableColumnText", "symbols": ["dataTableColumnText", (lexer.has("at") ? {type: "at"} : at)], "postprocess": data => data[0]+data[1].value},
120
121
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
121
122
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
122
123
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
@@ -143,6 +144,7 @@ var grammar = {
143
144
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
144
145
  {"name": "text", "symbols": ["text", (lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0]+data[1].value},
145
146
  {"name": "text", "symbols": ["text", "keywords"], "postprocess": data => data[0]+data[1]},
147
+ {"name": "text", "symbols": ["text", (lexer.has("at") ? {type: "at"} : at)], "postprocess": data => data[0]+data[1].value},
146
148
  {"name": "text", "symbols": ["text", (lexer.has("pipe") ? {type: "pipe"} : pipe)], "postprocess": data => data[0]+data[1].value},
147
149
  {"name": "text", "symbols": ["text", (lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => data[0]+data[1].value},
148
150
  {"name": "text", "symbols": ["text", (lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => data[0]+data[1].value},
package/src/index.js CHANGED
@@ -16,10 +16,10 @@ import {
16
16
 
17
17
  const featureRegex = /\.feature$/;
18
18
 
19
- const compileFeatureToJS = (config,featureSrc) => {
19
+ const compileFeatureToJS = async (config,featureSrc) => {
20
20
  const feature = parse(featureSrc);
21
21
 
22
- const code = generateFeature(config,feature);
22
+ const code = await generateFeature(config,feature);
23
23
 
24
24
  return code;
25
25
  }
@@ -79,7 +79,7 @@ export default function vitestCucumberPlugin() {
79
79
  },
80
80
  transform : async (src,id) => {
81
81
  if (featureRegex.test(id)) {
82
- const code = compileFeatureToJS(config,src);
82
+ const code = await compileFeatureToJS(config,src);
83
83
 
84
84
  log.debug('transform '+id+' -> '+code);
85
85
 
@@ -23,3 +23,22 @@ Feature: Data Tables
23
23
  | 2 | two |
24
24
  | 8 | eight |
25
25
  | 3 | three |
26
+
27
+ Scenario: You should be able to have different types of characters in the table cells
28
+ Given the following data:
29
+ | id | value |
30
+ | 9 | ~!@#$%^&*()_+ |
31
+ | 1 | Ֆունկցիոնալություն |
32
+ | 5 | ?>":{}[]`~';/., |
33
+ | 6 | |
34
+ | 7 | control |
35
+
36
+ When the following ids are removed:
37
+ | 7 |
38
+
39
+ Then the data will contain the following:
40
+ | id | value |
41
+ | 9 | ~!@#$%^&*()_+ |
42
+ | 1 | Ֆունկցիոնալություն |
43
+ | 5 | ?>":{}[]`~';/., |
44
+ | 6 | |
@@ -7,3 +7,4 @@
7
7
  <div class="text">{{text}}</div>
8
8
  <button @click="text = 'Button pressed!'">Push me!</button>
9
9
  </template>
10
+
@@ -3,7 +3,7 @@ import vitestCucumberPlugin from 'vitest-cucumber-plugin';
3
3
  import vue from '@vitejs/plugin-vue';
4
4
 
5
5
  export default defineConfig(({ mode }) => {
6
- const level = (mode === 'test-debug') ? 'info' : 'warn';
6
+ const level = (mode === 'test-debug') ? 'debug' : 'warn';
7
7
  return {
8
8
  plugins: [vue(),vitestCucumberPlugin()],
9
9
  test: {