vitest-cucumber-plugin 0.1.8 → 0.5.1

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
@@ -24,12 +24,19 @@ export default defineConfig({
24
24
  test: {
25
25
  include : [ '**/*.feature' ],
26
26
  cucumber : {
27
- tags : "<tags boolean expression>"
27
+ tags : "<tags boolean expression>", // Use this to filter the test via boolean tags expression
28
+ log : {
29
+ level : "<'fatal', 'error', 'warn', 'info', 'debug', 'trace' or 'silent'>",
30
+ file : "<log path>", // Write the logs to a file instead of stdio (the default)
31
+ }
28
32
  }
29
33
  },
30
34
  })
31
35
  ```
32
36
 
37
+ Setting the log level to 'info' will cause the plugin to generate logs useful for tracking the state through
38
+ the steps. You can pipe the logs through pino-pretty to make them more human readable.
39
+
33
40
  ### Writing tests
34
41
 
35
42
  Put feature files into the 'features/' directory and step definitions into the 'features/step_definitions/' directory.
@@ -106,9 +113,3 @@ Then('I should be told {string}', function (state,[ answer ], dataTable) {
106
113
 
107
114
  Currently, all step definition files must be in ECMAScript module format. CommonJS files might
108
115
  work, but this configuration isn't tested.
109
-
110
-
111
- ### Not yet implemented
112
-
113
- This plugin is not yet feature complete. Here is the list of features from Cucumber which aren't yet implemented:
114
- * Doc strings
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,5 @@
1
+ * v0.5.1 : Added info level logging for tracing state through steps. Also added a log file option.
2
+ * v0.5.0 : Implemented Doc Strings. Plugin is now feature complete.
1
3
  * v0.1.8 : Implemented Rule keyword
2
4
  * v0.1.7 : Implemented Hooks API
3
5
  * v0.1.6 : Implemented tags boolean expression support
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-cucumber-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.5.1",
4
4
  "description": "Plugin for Vitest which allows for tests to be written in Cucumber format.",
5
5
  "keywords": [
6
6
  "vite",
@@ -38,9 +38,9 @@ import {
38
38
  applyAfterStepHooks,
39
39
  } from 'vitest-cucumber-plugin';
40
40
  import { readdir } from 'node:fs/promises';
41
- import { log, setLogLevel } from 'vitest-cucumber-plugin';
41
+ import { log, logConfig } from 'vitest-cucumber-plugin';
42
42
 
43
- setLogLevel('${config.logLevel}');
43
+ logConfig(${JSON.stringify(config.log)});
44
44
 
45
45
  const importDirectory = async (directory) => {
46
46
  log.debug('importDirectory directory: '+directory);
package/src/gherkin.js CHANGED
@@ -26,6 +26,7 @@ var gherkin_umd$1 = {exports: {}};
26
26
  escapedNewline : '\\n',
27
27
  escapedBackSlash : '\\\\',
28
28
  scenarioOutline : ['Scenario Outline','Scenario Template'],
29
+ docString : ['```','"""'],
29
30
  word : {
30
31
  match : /[^ \t\n\:\|\@\*]+/,
31
32
  type : moo.keywords({
@@ -38,6 +39,13 @@ var gherkin_umd$1 = {exports: {}};
38
39
  }),
39
40
  },
40
41
  });
42
+
43
+ const trimWhitespace = (cols,str) => {
44
+ const lines = str.split('\n').slice(0,-1);
45
+ return fp.reduce((s,line) => {
46
+ return s+line.slice(cols)+'\n'
47
+ },'')(lines);
48
+ };
41
49
  var grammar = {
42
50
  Lexer: lexer,
43
51
  ParserRules: [
@@ -95,7 +103,7 @@ var gherkin_umd$1 = {exports: {}};
95
103
  (data) => { return { type : { type : 'examples', name : data[1] }, name : data[4] } }
96
104
  },
97
105
  {"name": "examplesKeyword", "symbols": [(lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0].value},
98
- {"name": "dataTable", "symbols": [], "postprocess": data => []},
106
+ {"name": "dataTable", "symbols": ["dataTableRow"], "postprocess": data => [data[0]]},
99
107
  {"name": "dataTable", "symbols": ["dataTable", "dataTableRow"], "postprocess": data => fp.concat(data[0],[data[1]])},
100
108
  {"name": "dataTableRow", "symbols": ["_", (lexer.has("pipe") ? {type: "pipe"} : pipe), "dataTableColumns", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[2]},
101
109
  {"name": "dataTableColumns", "symbols": [], "postprocess": data => []},
@@ -108,12 +116,14 @@ var gherkin_umd$1 = {exports: {}};
108
116
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
109
117
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
110
118
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
111
- {"name": "steps", "symbols": ["stepAndTable", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
119
+ {"name": "steps", "symbols": ["step", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
112
120
  {"name": "moreSteps", "symbols": [], "postprocess": data => []},
113
- {"name": "moreSteps", "symbols": ["moreSteps", "stepAndTable"], "postprocess": data => fp.concat(data[0],data[1])},
121
+ {"name": "moreSteps", "symbols": ["moreSteps", "step"], "postprocess": data => fp.concat(data[0],data[1])},
114
122
  {"name": "moreSteps", "symbols": ["moreSteps", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]},
115
- {"name": "step", "symbols": ["_", "stepKeyword", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => { return { type : data[1], text : data[2].trim() } }},
116
- {"name": "stepAndTable", "symbols": ["step", "dataTable"], "postprocess": data => fp.set('dataTable',data[1],data[0])},
123
+ {"name": "step", "symbols": ["stepStatement"]},
124
+ {"name": "step", "symbols": ["stepStatement", "dataTable"], "postprocess": data => fp.set('dataTable',data[1],data[0])},
125
+ {"name": "step", "symbols": ["stepStatement", "docString"], "postprocess": data => fp.set('docString',data[1],data[0])},
126
+ {"name": "stepStatement", "symbols": ["_", "stepKeyword", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => { return { type : data[1], text : data[2].trim() } }},
117
127
  {"name": "stepKeyword", "symbols": [(lexer.has("step") ? {type: "step"} : step)], "postprocess": (data) => { return { type : 'step', name : data[0].value } }},
118
128
  {"name": "text", "symbols": [], "postprocess": data => ''},
119
129
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
@@ -137,6 +147,18 @@ var gherkin_umd$1 = {exports: {}};
137
147
  }
138
148
  },
139
149
  {"name": "freeform", "symbols": ["freeform", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]+'\n'},
150
+ {"name": "docString", "symbols": ["docStringStatement", "docText", "docStringStatement"], "postprocess":
151
+ data => fp.set('text',trimWhitespace(data[0].ws.length,data[1]),data[0])
152
+ },
153
+ {"name": "docStringStatement", "symbols": ["_", (lexer.has("docString") ? {type: "docString"} : docString), "contentType", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess":
154
+ (data) => { return { type : { type : 'docString', name : data[1].value }, ws : data[0], contentType : data[2] } }
155
+ },
156
+ {"name": "contentType", "symbols": [], "postprocess": data => null},
157
+ {"name": "contentType", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => null},
158
+ {"name": "contentType", "symbols": [(lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0].value},
159
+ {"name": "docText", "symbols": [], "postprocess": data => ''},
160
+ {"name": "docText", "symbols": ["docText", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[0]+data[1]+data[2].value},
161
+ {"name": "docText", "symbols": ["docText", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]+data[1].value},
140
162
  {"name": "_", "symbols": [], "postprocess": data => ''},
141
163
  {"name": "_", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0].value},
142
164
  {"name": "emptyLines", "symbols": [], "postprocess": data => ''},
package/src/gherkin.ne CHANGED
@@ -13,6 +13,7 @@ const lexer = moo.compile({
13
13
  escapedNewline : '\\n',
14
14
  escapedBackSlash : '\\\\',
15
15
  scenarioOutline : ['Scenario Outline','Scenario Template'],
16
+ docString : ['```','"""'],
16
17
  word : {
17
18
  match : /[^ \t\n\:\|\@\*]+/,
18
19
  type : moo.keywords({
@@ -25,6 +26,13 @@ const lexer = moo.compile({
25
26
  }),
26
27
  },
27
28
  });
29
+
30
+ const trimWhitespace = (cols,str) => {
31
+ const lines = str.split('\n').slice(0,-1);
32
+ return fp.reduce((s,line) => {
33
+ return s+line.slice(cols)+'\n'
34
+ },'')(lines);
35
+ };
28
36
  %}
29
37
 
30
38
  @lexer lexer
@@ -98,7 +106,7 @@ examplesStatement -> _ examplesKeyword _ %colon text %newline {%
98
106
  %}
99
107
  examplesKeyword -> %examples {% data => data[0].value %}
100
108
 
101
- dataTable -> null {% data => [] %}
109
+ dataTable -> dataTableRow {% data => [data[0]] %}
102
110
  | dataTable dataTableRow {% data => fp.concat(data[0],[data[1]]) %}
103
111
 
104
112
  dataTableRow -> _ %pipe dataTableColumns %newline {% data => data[2] %}
@@ -116,14 +124,17 @@ escapedColumnCharaters -> %escapedPipe {% data => '|' %}
116
124
  | %escapedBackSlash {% data => '\\' %}
117
125
  | %escapedNewline {% data => '\n' %}
118
126
 
119
- steps -> stepAndTable moreSteps {% data => fp.concat(data[0],data[1]) %}
127
+ steps -> step moreSteps {% data => fp.concat(data[0],data[1]) %}
120
128
 
121
129
  moreSteps -> null {% data => [] %}
122
- | moreSteps stepAndTable {% data => fp.concat(data[0],data[1]) %}
130
+ | moreSteps step {% data => fp.concat(data[0],data[1]) %}
123
131
  | moreSteps %emptyLine {% data => data[0] %}
124
132
 
125
- step -> _ stepKeyword text %newline {% data => { return { type : data[1], text : data[2].trim() } } %}
126
- stepAndTable -> step dataTable {% data => fp.set('dataTable',data[1],data[0]) %}
133
+ step -> stepStatement
134
+ | stepStatement dataTable {% data => fp.set('dataTable',data[1],data[0]) %}
135
+ | stepStatement docString {% data => fp.set('docString',data[1],data[0]) %}
136
+
137
+ stepStatement -> _ stepKeyword text %newline {% data => { return { type : data[1], text : data[2].trim() } } %}
127
138
 
128
139
  stepKeyword -> %step {% (data) => { return { type : 'step', name : data[0].value } } %}
129
140
 
@@ -153,6 +164,21 @@ freeform -> null {% data => '' %}
153
164
  %}
154
165
  | freeform %emptyLine {% data => data[0]+'\n' %}
155
166
 
167
+ docString -> docStringStatement docText docStringStatement {%
168
+ data => fp.set('text',trimWhitespace(data[0].ws.length,data[1]),data[0])
169
+ %}
170
+ docStringStatement -> _ %docString contentType %newline {%
171
+ (data) => { return { type : { type : 'docString', name : data[1].value }, ws : data[0], contentType : data[2] } }
172
+ %}
173
+
174
+ contentType -> null {% data => null %}
175
+ | %ws {% data => null %}
176
+ | %word {% data => data[0].value %}
177
+
178
+ docText -> null {% data => '' %}
179
+ | docText text %newline {% data => data[0]+data[1]+data[2].value %}
180
+ | docText %emptyLine {% data => data[0]+data[1].value %}
181
+
156
182
  _ -> null {% data => '' %}
157
183
  | %ws {% data => data[0].value %}
158
184
 
@@ -17,6 +17,7 @@ const lexer = moo.compile({
17
17
  escapedNewline : '\\n',
18
18
  escapedBackSlash : '\\\\',
19
19
  scenarioOutline : ['Scenario Outline','Scenario Template'],
20
+ docString : ['```','"""'],
20
21
  word : {
21
22
  match : /[^ \t\n\:\|\@\*]+/,
22
23
  type : moo.keywords({
@@ -29,6 +30,13 @@ const lexer = moo.compile({
29
30
  }),
30
31
  },
31
32
  });
33
+
34
+ const trimWhitespace = (cols,str) => {
35
+ const lines = str.split('\n').slice(0,-1);
36
+ return fp.reduce((s,line) => {
37
+ return s+line.slice(cols)+'\n'
38
+ },'')(lines);
39
+ };
32
40
  var grammar = {
33
41
  Lexer: lexer,
34
42
  ParserRules: [
@@ -86,7 +94,7 @@ var grammar = {
86
94
  (data) => { return { type : { type : 'examples', name : data[1] }, name : data[4] } }
87
95
  },
88
96
  {"name": "examplesKeyword", "symbols": [(lexer.has("examples") ? {type: "examples"} : examples)], "postprocess": data => data[0].value},
89
- {"name": "dataTable", "symbols": [], "postprocess": data => []},
97
+ {"name": "dataTable", "symbols": ["dataTableRow"], "postprocess": data => [data[0]]},
90
98
  {"name": "dataTable", "symbols": ["dataTable", "dataTableRow"], "postprocess": data => fp.concat(data[0],[data[1]])},
91
99
  {"name": "dataTableRow", "symbols": ["_", (lexer.has("pipe") ? {type: "pipe"} : pipe), "dataTableColumns", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[2]},
92
100
  {"name": "dataTableColumns", "symbols": [], "postprocess": data => []},
@@ -99,12 +107,14 @@ var grammar = {
99
107
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedPipe") ? {type: "escapedPipe"} : escapedPipe)], "postprocess": data => '|'},
100
108
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedBackSlash") ? {type: "escapedBackSlash"} : escapedBackSlash)], "postprocess": data => '\\'},
101
109
  {"name": "escapedColumnCharaters", "symbols": [(lexer.has("escapedNewline") ? {type: "escapedNewline"} : escapedNewline)], "postprocess": data => '\n'},
102
- {"name": "steps", "symbols": ["stepAndTable", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
110
+ {"name": "steps", "symbols": ["step", "moreSteps"], "postprocess": data => fp.concat(data[0],data[1])},
103
111
  {"name": "moreSteps", "symbols": [], "postprocess": data => []},
104
- {"name": "moreSteps", "symbols": ["moreSteps", "stepAndTable"], "postprocess": data => fp.concat(data[0],data[1])},
112
+ {"name": "moreSteps", "symbols": ["moreSteps", "step"], "postprocess": data => fp.concat(data[0],data[1])},
105
113
  {"name": "moreSteps", "symbols": ["moreSteps", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]},
106
- {"name": "step", "symbols": ["_", "stepKeyword", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => { return { type : data[1], text : data[2].trim() } }},
107
- {"name": "stepAndTable", "symbols": ["step", "dataTable"], "postprocess": data => fp.set('dataTable',data[1],data[0])},
114
+ {"name": "step", "symbols": ["stepStatement"]},
115
+ {"name": "step", "symbols": ["stepStatement", "dataTable"], "postprocess": data => fp.set('dataTable',data[1],data[0])},
116
+ {"name": "step", "symbols": ["stepStatement", "docString"], "postprocess": data => fp.set('docString',data[1],data[0])},
117
+ {"name": "stepStatement", "symbols": ["_", "stepKeyword", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => { return { type : data[1], text : data[2].trim() } }},
108
118
  {"name": "stepKeyword", "symbols": [(lexer.has("step") ? {type: "step"} : step)], "postprocess": (data) => { return { type : 'step', name : data[0].value } }},
109
119
  {"name": "text", "symbols": [], "postprocess": data => ''},
110
120
  {"name": "text", "symbols": ["text", (lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0]+data[1].value},
@@ -128,6 +138,18 @@ var grammar = {
128
138
  }
129
139
  },
130
140
  {"name": "freeform", "symbols": ["freeform", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]+'\n'},
141
+ {"name": "docString", "symbols": ["docStringStatement", "docText", "docStringStatement"], "postprocess":
142
+ data => fp.set('text',trimWhitespace(data[0].ws.length,data[1]),data[0])
143
+ },
144
+ {"name": "docStringStatement", "symbols": ["_", (lexer.has("docString") ? {type: "docString"} : docString), "contentType", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess":
145
+ (data) => { return { type : { type : 'docString', name : data[1].value }, ws : data[0], contentType : data[2] } }
146
+ },
147
+ {"name": "contentType", "symbols": [], "postprocess": data => null},
148
+ {"name": "contentType", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => null},
149
+ {"name": "contentType", "symbols": [(lexer.has("word") ? {type: "word"} : word)], "postprocess": data => data[0].value},
150
+ {"name": "docText", "symbols": [], "postprocess": data => ''},
151
+ {"name": "docText", "symbols": ["docText", "text", (lexer.has("newline") ? {type: "newline"} : newline)], "postprocess": data => data[0]+data[1]+data[2].value},
152
+ {"name": "docText", "symbols": ["docText", (lexer.has("emptyLine") ? {type: "emptyLine"} : emptyLine)], "postprocess": data => data[0]+data[1].value},
131
153
  {"name": "_", "symbols": [], "postprocess": data => ''},
132
154
  {"name": "_", "symbols": [(lexer.has("ws") ? {type: "ws"} : ws)], "postprocess": data => data[0].value},
133
155
  {"name": "emptyLines", "symbols": [], "postprocess": data => ''},
package/src/hooks.js CHANGED
@@ -11,6 +11,16 @@ const allHooks = {
11
11
  afterStep : [],
12
12
  };
13
13
 
14
+ const hookNames = {
15
+ beforeAll : 'BeforeAll',
16
+ before : 'Before',
17
+ beforeStep : 'BeforeStep',
18
+ afterAll : 'AfterAll',
19
+ after : 'After',
20
+ afterStep : 'AfterStep',
21
+ }
22
+
23
+
14
24
  const applyHooks = async (hooksName,state,tags) => {
15
25
  const hooks = allHooks[hooksName];
16
26
  log.debug('applyHooks: '+hooksName+' state: '+JSON.stringify(state));
@@ -23,8 +33,10 @@ const applyHooks = async (hooksName,state,tags) => {
23
33
 
24
34
  log.debug('applyHooks match? '+result+' tags: '+JSON.stringify(tags));
25
35
  if (result) {
36
+ const origState = state;
26
37
  state = await hook.f(state);
27
- log.debug('applyHooks name: '+hook.name+' new state: '+JSON.stringify(state));
38
+ log.info(hookNames[hooksName]+'(\''+hook.name+'\') ('+JSON.stringify(origState)+') => '+
39
+ JSON.stringify(state));
28
40
  }
29
41
  }
30
42
  return state;
package/src/index.js CHANGED
@@ -2,7 +2,7 @@ import _ from 'lodash/fp.js';
2
2
  import { addStepDefinition, findStepDefinitionMatch } from './steps.js';
3
3
  import { parameterizeText } from './parameterize.js';
4
4
  import { generateFeature } from './generate/index.js';
5
- import { log, setLogLevel } from './logger.js';
5
+ import { log, logConfig } from './logger.js';
6
6
  import { parse } from './parse.js';
7
7
  import { tagsFunction } from './tags.js';
8
8
  import {
@@ -35,7 +35,7 @@ export {
35
35
  applyAfterStepHooks,
36
36
  };
37
37
 
38
- export { setLogLevel, log };
38
+ export { log, logConfig };
39
39
 
40
40
  export const Given = addStepDefinition;
41
41
  export const When = addStepDefinition;
@@ -45,7 +45,12 @@ export const Test = (state,step) => {
45
45
  log.debug('Test step: '+JSON.stringify(step)+' state:'+JSON.stringify(state));
46
46
  const stepDefinitionMatch = findStepDefinitionMatch(step);
47
47
 
48
- const newState = stepDefinitionMatch.stepDefinition.f(state,stepDefinitionMatch.parameters,step.dataTable);
48
+ const extraData = step.dataTable ? step.dataTable : (step.docString ? step.docString.text : null );
49
+
50
+ const newState = stepDefinitionMatch.stepDefinition.f(state,stepDefinitionMatch.parameters,extraData);
51
+ log.info(step.type.name+'(\''+stepDefinitionMatch.stepDefinition.expression+'\') ('+
52
+ JSON.stringify(state)+','+JSON.stringify(stepDefinitionMatch.parameters)+','+JSON.stringify(extraData)+
53
+ ') => '+JSON.stringify(newState));
49
54
  log.debug('Test newState: '+JSON.stringify(newState));
50
55
 
51
56
  return newState;
@@ -64,8 +69,9 @@ export default function vitestCucumberPlugin() {
64
69
  return {
65
70
  name : 'vitest-cucumber-transform',
66
71
  configResolved : (resolvedConfig) => {
67
- config = _.defaults({ root : resolvedConfig.root, logLevel : 'warn' },_.get('test.cucumber',resolvedConfig))
68
- setLogLevel(config.logLevel);
72
+ config = _.defaults({ root : resolvedConfig.root, log : { level : 'warn' } },
73
+ _.get('test.cucumber',resolvedConfig))
74
+ logConfig(config.log);
69
75
 
70
76
  config = _.set('tagsFunction',tagsFunction(_.get('tags',config)),config);
71
77
 
package/src/logger.js CHANGED
@@ -1,7 +1,14 @@
1
+ import _ from 'lodash/fp.js';
1
2
  import pino from 'pino';
2
3
 
3
- export const log = pino();
4
+ export var log = pino();
4
5
 
5
6
  log.level = 'warn';
6
7
 
7
- export const setLogLevel = (logLevel) => { log.level = logLevel };
8
+ export const logConfig = (config) => {
9
+ if (_.has('file',config)) {
10
+ log = pino(config,config.file);
11
+ } else {
12
+ log = pino(config);
13
+ }
14
+ };
@@ -4,6 +4,6 @@ import vitestCucumberPlugin from 'vitest-cucumber-plugin';
4
4
  export default defineConfig({
5
5
  plugins: [vitestCucumberPlugin()],
6
6
  test: {
7
- include : [ '**/*.feature' ]
7
+ include : [ '**/*.feature' ],
8
8
  },
9
9
  })
@@ -1,9 +1,13 @@
1
1
  import { defineConfig } from 'vitest/config'
2
2
  import vitestCucumberPlugin from 'vitest-cucumber-plugin';
3
3
 
4
- export default defineConfig({
5
- plugins: [vitestCucumberPlugin()],
6
- test: {
7
- include : [ '**/*.feature' ]
8
- },
9
- })
4
+ export default defineConfig(({ mode }) => {
5
+ const level = (mode === 'test-debug') ? 'info' : 'warn';
6
+ return {
7
+ plugins: [vitestCucumberPlugin()],
8
+ test: {
9
+ include : [ '**/*.feature' ],
10
+ cucumber : { log : { level } },
11
+ },
12
+ }
13
+ });
@@ -0,0 +1,21 @@
1
+ Feature: Doc Strings
2
+ Scenario: You should be able to use Doc Strings with Given, When and Then statements
3
+ Given the following doc string:
4
+ """markdown
5
+ This is some cool text.
6
+
7
+ It is fun.
8
+ """
9
+
10
+ When the following doc string is appended:
11
+ ```
12
+ This is more fun.
13
+ ```
14
+
15
+ Then final doc string will look like this:
16
+ """
17
+ This is some cool text.
18
+
19
+ It is fun.
20
+ This is more fun.
21
+ """
@@ -0,0 +1,15 @@
1
+ import { Given, When, Then, DataTable } from 'vitest-cucumber-plugin';
2
+ import { expect } from 'vitest'
3
+ import _ from 'lodash/fp';
4
+
5
+ Given('the following doc string:',(state,params,docString) => {
6
+ return _.set('docString',docString,state);
7
+ });
8
+
9
+ When('the following doc string is appended:',(state,params,docString) => {
10
+ return _.set('docString',_.getOr('','docString',state)+docString,state);
11
+ });
12
+
13
+ Then('final doc string will look like this:',(state,params,docString) => {
14
+ expect(docString).toEqual(_.get('docString',state));
15
+ });