vitest-cucumber-plugin 0.6.0 → 0.6.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.
- package/RELEASE_NOTES.md +2 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/generate/example.d.ts +5 -0
- package/dist/generate/example.d.ts.map +1 -0
- package/{src → dist}/generate/example.js +7 -10
- package/dist/generate/example.js.map +1 -0
- package/dist/generate/examples.d.ts +5 -0
- package/dist/generate/examples.d.ts.map +1 -0
- package/dist/generate/examples.js +46 -0
- package/dist/generate/examples.js.map +1 -0
- package/dist/generate/feature.d.ts +10 -0
- package/dist/generate/feature.d.ts.map +1 -0
- package/dist/generate/feature.js +77 -0
- package/dist/generate/feature.js.map +1 -0
- package/dist/generate/index.d.ts +3 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +3 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/generate/rule.d.ts +5 -0
- package/dist/generate/rule.d.ts.map +1 -0
- package/{src → dist}/generate/rule.js +9 -12
- package/dist/generate/rule.js.map +1 -0
- package/dist/generate/scenario-outline.d.ts +5 -0
- package/dist/generate/scenario-outline.d.ts.map +1 -0
- package/dist/generate/scenario-outline.js +18 -0
- package/dist/generate/scenario-outline.js.map +1 -0
- package/dist/generate/tests.d.ts +4 -0
- package/dist/generate/tests.d.ts.map +1 -0
- package/{src → dist}/generate/tests.js +9 -9
- package/dist/generate/tests.js.map +1 -0
- package/dist/generate/util.d.ts +6 -0
- package/dist/generate/util.d.ts.map +1 -0
- package/{src → dist}/generate/util.js +5 -5
- package/dist/generate/util.js.map +1 -0
- package/dist/gherkin-lexer-shared.d.ts +6 -0
- package/dist/gherkin-lexer-shared.d.ts.map +1 -0
- package/dist/gherkin-lexer-shared.js +4 -0
- package/dist/gherkin-lexer-shared.js.map +1 -0
- package/dist/gherkin-lexer.d.ts +4 -0
- package/dist/gherkin-lexer.d.ts.map +1 -0
- package/dist/gherkin-lexer.js +68 -0
- package/dist/gherkin-lexer.js.map +1 -0
- package/{src → dist}/gherkin.js +1 -1
- package/{src → dist}/gherkin.umd.js +1 -1
- package/dist/hooks.d.ts +25 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +94 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +5 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/parameterize.d.ts +3 -0
- package/dist/parameterize.d.ts.map +1 -0
- package/dist/parameterize.js +8 -0
- package/dist/parameterize.js.map +1 -0
- package/dist/parse.d.ts +3 -0
- package/dist/parse.d.ts.map +1 -0
- package/{src → dist}/parse.js +5 -9
- package/dist/parse.js.map +1 -0
- package/dist/state.d.ts +4 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +2 -0
- package/dist/state.js.map +1 -0
- package/dist/statement.d.ts +71 -0
- package/dist/statement.d.ts.map +1 -0
- package/dist/statement.js +10 -0
- package/dist/statement.js.map +1 -0
- package/dist/steps.d.ts +20 -0
- package/dist/steps.d.ts.map +1 -0
- package/{src → dist}/steps.js +16 -23
- package/dist/steps.js.map +1 -0
- package/dist/tags.d.ts +5 -0
- package/dist/tags.d.ts.map +1 -0
- package/{src → dist}/tags.js +15 -28
- package/dist/tags.js.map +1 -0
- package/dist/vitest-cucumber-plugin.d.ts +13 -0
- package/dist/vitest-cucumber-plugin.d.ts.map +1 -0
- package/dist/vitest-cucumber-plugin.js +69 -0
- package/dist/vitest-cucumber-plugin.js.map +1 -0
- package/package.json +64 -34
- package/generate-parsers +0 -6
- package/rollup-gherkin.js +0 -12
- package/rollup-tags-expression.js +0 -11
- package/run-tests +0 -9
- package/src/generate/examples.js +0 -48
- package/src/generate/feature.js +0 -72
- package/src/generate/index.js +0 -15
- package/src/generate/scenario-outline.js +0 -21
- package/src/gherkin-lexer-shared.cjs +0 -4
- package/src/gherkin-lexer.js +0 -63
- package/src/gherkin.ne +0 -211
- package/src/hooks.js +0 -77
- package/src/index.js +0 -95
- package/src/logger.js +0 -14
- package/src/parameterize.js +0 -7
- package/src/tags-expression.ne +0 -43
- package/tests/background/features/background.feature +0 -25
- package/tests/background/features/step_definitions/steps.js +0 -30
- package/tests/background/features/support/hooks.js +0 -3
- package/tests/background/package-lock.json +0 -1204
- package/tests/background/package.json +0 -11
- package/tests/background/vite.config.js +0 -13
- package/tests/comments/features/is-it-friday.feature +0 -10
- package/tests/comments/features/step_definitions/stepdefs.js +0 -15
- package/tests/comments/package-lock.json +0 -1933
- package/tests/comments/package.json +0 -11
- package/tests/comments/vite.config.js +0 -9
- package/tests/data-tables/features/data-tables-escaping.feature +0 -27
- package/tests/data-tables/features/data-tables.feature +0 -44
- package/tests/data-tables/features/step_definitions/data-tables.js +0 -21
- package/tests/data-tables/package-lock.json +0 -1933
- package/tests/data-tables/package.json +0 -11
- package/tests/data-tables/vite.config.js +0 -13
- package/tests/doc-strings/features/doc-strings.feature +0 -21
- package/tests/doc-strings/features/step_definitions/doc-strings.js +0 -15
- package/tests/doc-strings/package-lock.json +0 -1933
- package/tests/doc-strings/package.json +0 -11
- package/tests/doc-strings/vite.config.js +0 -13
- package/tests/hooks/features/after-all.feature +0 -5
- package/tests/hooks/features/after.feature +0 -5
- package/tests/hooks/features/before-all.feature +0 -14
- package/tests/hooks/features/before-step.feature +0 -6
- package/tests/hooks/features/before.feature +0 -14
- package/tests/hooks/features/step_definitions/steps.js +0 -28
- package/tests/hooks/features/support/hooks.js +0 -75
- package/tests/hooks/features/support/tags-hooks.js +0 -11
- package/tests/hooks/features/tags.feature +0 -14
- package/tests/hooks/package-lock.json +0 -1204
- package/tests/hooks/package.json +0 -11
- package/tests/hooks/vite.config.js +0 -13
- package/tests/is-it-friday/features/is-it-friday.feature +0 -7
- package/tests/is-it-friday/features/step_definitions/stepdefs.js +0 -15
- package/tests/is-it-friday/package-lock.json +0 -1933
- package/tests/is-it-friday/package.json +0 -11
- package/tests/is-it-friday/vite.config.js +0 -13
- package/tests/is-it-friday-scenario-outline/features/is-it-friday.feature +0 -13
- package/tests/is-it-friday-scenario-outline/features/step_definitions/stepdefs.js +0 -15
- package/tests/is-it-friday-scenario-outline/package-lock.json +0 -1933
- package/tests/is-it-friday-scenario-outline/package.json +0 -11
- package/tests/is-it-friday-scenario-outline/vite.config.js +0 -9
- package/tests/is-it-friday-two-scenarios/features/is-it-friday.feature +0 -12
- package/tests/is-it-friday-two-scenarios/features/step_definitions/stepdefs.js +0 -19
- package/tests/is-it-friday-two-scenarios/package-lock.json +0 -1933
- package/tests/is-it-friday-two-scenarios/package.json +0 -11
- package/tests/is-it-friday-two-scenarios/vite.config.js +0 -9
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/features/friday.feature +0 -7
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/features/step_definitions/stepdefs.js +0 -19
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/features/sunday.feature +0 -8
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/package-lock.json +0 -1933
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/package.json +0 -11
- package/tests/is-it-friday-two-scenarios-multiple-feature-files/vite.config.js +0 -9
- package/tests/keyword-aliases/features/scenario-outline.feature +0 -20
- package/tests/keyword-aliases/features/scenario.feature +0 -14
- package/tests/keyword-aliases/features/step_definitions/steps.js +0 -30
- package/tests/keyword-aliases/features/steps.feature +0 -28
- package/tests/keyword-aliases/features/support/hooks.js +0 -6
- package/tests/keyword-aliases/package-lock.json +0 -1933
- package/tests/keyword-aliases/package.json +0 -11
- package/tests/keyword-aliases/vite.config.js +0 -9
- package/tests/languages/features/en.feature +0 -8
- package/tests/languages/features/no.feature +0 -10
- package/tests/languages/features/step_definitions/en.js +0 -15
- package/tests/languages/features/step_definitions/no.js +0 -21
- package/tests/languages/package-lock.json +0 -1204
- package/tests/languages/package.json +0 -11
- package/tests/languages/vite.config.js +0 -13
- package/tests/rule/features/rule.feature +0 -14
- package/tests/rule/features/step_definitions/stepdefs.js +0 -19
- package/tests/rule/package-lock.json +0 -1933
- package/tests/rule/package.json +0 -11
- package/tests/rule/vite.config.js +0 -9
- package/tests/tags/features/skip.feature +0 -9
- package/tests/tags/features/step_definitions/steps.js +0 -30
- package/tests/tags/features/support/hooks.js +0 -6
- package/tests/tags/features/tags-scenario-outline.feature +0 -37
- package/tests/tags/features/tags.feature +0 -26
- package/tests/tags/package-lock.json +0 -1204
- package/tests/tags/package.json +0 -11
- package/tests/tags/vite.config.js +0 -12
- package/tests/vue/features/step_definitions/test.js +0 -25
- package/tests/vue/features/support/components.js +0 -19
- package/tests/vue/features/test.feature +0 -10
- package/tests/vue/package-lock.json +0 -2164
- package/tests/vue/package.json +0 -18
- package/tests/vue/src/test.vue +0 -10
- package/tests/vue/vite.config.js +0 -15
- /package/{src → dist}/gherkin-languages.json +0 -0
- /package/{src → dist}/tags-expression.js +0 -0
- /package/{src → dist}/tags-expression.umd.js +0 -0
package/src/index.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash/fp.js';
|
|
2
|
-
import { addStepDefinition, findStepDefinitionMatch } from './steps.js';
|
|
3
|
-
import { parameterizeText } from './parameterize.js';
|
|
4
|
-
import { generateFeature } from './generate/index.js';
|
|
5
|
-
import { log, logConfig } from './logger.js';
|
|
6
|
-
import { parse } from './parse.js';
|
|
7
|
-
import { tagsFunction } from './tags.js';
|
|
8
|
-
import {
|
|
9
|
-
BeforeAll, applyBeforeAllHooks,
|
|
10
|
-
Before, applyBeforeHooks,
|
|
11
|
-
AfterAll, applyAfterAllHooks,
|
|
12
|
-
After, applyAfterHooks,
|
|
13
|
-
BeforeStep, applyBeforeStepHooks,
|
|
14
|
-
AfterStep, applyAfterStepHooks,
|
|
15
|
-
} from './hooks.js';
|
|
16
|
-
import { gherkinLexerConfig } from './gherkin-lexer.js';
|
|
17
|
-
|
|
18
|
-
const featureRegex = /\.feature$/;
|
|
19
|
-
|
|
20
|
-
const compileFeatureToJS = async (config,featureSrc) => {
|
|
21
|
-
const feature = await parse(featureSrc);
|
|
22
|
-
|
|
23
|
-
const code = await generateFeature(config,feature);
|
|
24
|
-
|
|
25
|
-
return code;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { BeforeAll, Before, AfterAll, After, BeforeStep, AfterStep };
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
applyBeforeAllHooks,
|
|
32
|
-
applyBeforeHooks,
|
|
33
|
-
applyAfterAllHooks,
|
|
34
|
-
applyAfterHooks,
|
|
35
|
-
applyBeforeStepHooks,
|
|
36
|
-
applyAfterStepHooks,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { log, logConfig };
|
|
40
|
-
|
|
41
|
-
export const Given = addStepDefinition;
|
|
42
|
-
export const When = addStepDefinition;
|
|
43
|
-
export const Then = addStepDefinition;
|
|
44
|
-
|
|
45
|
-
export const Test = (state,step) => {
|
|
46
|
-
log.debug({ step, state }, 'Test step');
|
|
47
|
-
const stepDefinitionMatch = findStepDefinitionMatch(step);
|
|
48
|
-
|
|
49
|
-
const extraData = step.dataTable ? step.dataTable : (step.docString ? step.docString.text : null );
|
|
50
|
-
|
|
51
|
-
const newState = stepDefinitionMatch.stepDefinition.f(state,stepDefinitionMatch.parameters,extraData);
|
|
52
|
-
log.info({ state, newState, extraData, parameters: stepDefinitionMatch.parameters }, `${step.type.name}('${stepDefinitionMatch.stepDefinition.expression}')`);
|
|
53
|
-
log.debug({ newState }, 'Test newState');
|
|
54
|
-
|
|
55
|
-
return newState;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const DataTable = (dataTable) => {
|
|
59
|
-
const parameters = _.first(dataTable);
|
|
60
|
-
const rows = _.tail(dataTable);
|
|
61
|
-
|
|
62
|
-
return _.map((row) => _.zipObject(parameters,row))(rows);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default function vitestCucumberPlugin() {
|
|
66
|
-
let config;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
name : 'vitest-cucumber-transform',
|
|
70
|
-
configResolved : (resolvedConfig) => {
|
|
71
|
-
config = _.defaults({ root : resolvedConfig.root, log : { level : 'warn' }, language : 'en' },
|
|
72
|
-
_.get('test.cucumber',resolvedConfig))
|
|
73
|
-
logConfig(config.log);
|
|
74
|
-
|
|
75
|
-
config = _.set('tagsFunction',tagsFunction(_.get('tags',config)),config);
|
|
76
|
-
|
|
77
|
-
log.debug({ config }, 'config');
|
|
78
|
-
|
|
79
|
-
// Nearley has no mechanism for passing user data into the parser so need to do some hacky stuff here
|
|
80
|
-
// and setup some globals to get around the limitations.
|
|
81
|
-
gherkinLexerConfig(config);
|
|
82
|
-
},
|
|
83
|
-
transform : async (src,id) => {
|
|
84
|
-
if (featureRegex.test(id)) {
|
|
85
|
-
const code = await compileFeatureToJS(config,src);
|
|
86
|
-
|
|
87
|
-
log.debug(`transform ${id} -> ${code}`);
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
code
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/logger.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash/fp.js';
|
|
2
|
-
import pino from 'pino';
|
|
3
|
-
|
|
4
|
-
export var log = pino();
|
|
5
|
-
|
|
6
|
-
log.level = 'warn';
|
|
7
|
-
|
|
8
|
-
export const logConfig = (config) => {
|
|
9
|
-
if (_.has('file',config)) {
|
|
10
|
-
log = pino(config,config.file);
|
|
11
|
-
} else {
|
|
12
|
-
log = pino(config);
|
|
13
|
-
}
|
|
14
|
-
};
|
package/src/parameterize.js
DELETED
package/src/tags-expression.ne
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
@{%
|
|
2
|
-
const fp = require('lodash/fp.js');
|
|
3
|
-
const moo = require('moo');
|
|
4
|
-
const lexer = moo.compile({
|
|
5
|
-
and : 'and',
|
|
6
|
-
or : 'or',
|
|
7
|
-
not : 'not',
|
|
8
|
-
openParen : '(',
|
|
9
|
-
closeParen : ')',
|
|
10
|
-
newline : { match : '\n', lineBreaks : true },
|
|
11
|
-
ws : /[ \t]+/,
|
|
12
|
-
tag : /\@[\w\.]+/,
|
|
13
|
-
});
|
|
14
|
-
%}
|
|
15
|
-
|
|
16
|
-
@lexer lexer
|
|
17
|
-
|
|
18
|
-
main -> expression %newline {% data => data[0] %}
|
|
19
|
-
|
|
20
|
-
expression -> tag {% data => data[0] %}
|
|
21
|
-
| unaryOperation {% data => data[0] %}
|
|
22
|
-
| binaryOperation {% data => data[0] %}
|
|
23
|
-
| parenOperation {% data => data[0] %}
|
|
24
|
-
|
|
25
|
-
parenOperation -> %openParen _ expression _ %closeParen {% data => data[2] %}
|
|
26
|
-
|
|
27
|
-
unaryOperation -> %not %ws unaryExpression {% data => { return { operator : 'not', expression : data[2] } } %}
|
|
28
|
-
|
|
29
|
-
unaryExpression -> tag {% id %}
|
|
30
|
-
| parenOperation {% id %}
|
|
31
|
-
|
|
32
|
-
binaryOperation -> expression _ binaryOperator _ expression {%
|
|
33
|
-
data => { return { operator : data[2], left : data[0], right : data[4] } }
|
|
34
|
-
%}
|
|
35
|
-
|
|
36
|
-
binaryOperator -> %and {% data => data[0].value %}
|
|
37
|
-
| %or {% data => data[0].value %}
|
|
38
|
-
|
|
39
|
-
tag -> %tag {% data => data[0].value.slice(1) %}
|
|
40
|
-
|
|
41
|
-
_ -> null
|
|
42
|
-
| %ws
|
|
43
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Feature: The Background keyword behaviors
|
|
2
|
-
The Background keyword allow you to add context to scenarios that follow it.
|
|
3
|
-
|
|
4
|
-
# This is the background.
|
|
5
|
-
Background: Set up some background data
|
|
6
|
-
It's the cool thing to do.
|
|
7
|
-
|
|
8
|
-
Given I have a "orange"
|
|
9
|
-
And I have a "grape"
|
|
10
|
-
|
|
11
|
-
Scenario: What's the scenario?
|
|
12
|
-
Given I have a "apple"
|
|
13
|
-
When I get a "pea"
|
|
14
|
-
Then I have the following items:
|
|
15
|
-
| orange |
|
|
16
|
-
| grape |
|
|
17
|
-
| apple |
|
|
18
|
-
| pea |
|
|
19
|
-
|
|
20
|
-
Scenario: It's another scenario!
|
|
21
|
-
When I get a "pea"
|
|
22
|
-
Then I have the following items:
|
|
23
|
-
| orange |
|
|
24
|
-
| grape |
|
|
25
|
-
| pea |
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Given, When, Then, DataTable } from 'vitest-cucumber-plugin';
|
|
2
|
-
import { expect } from 'vitest'
|
|
3
|
-
import _ from 'lodash/fp';
|
|
4
|
-
|
|
5
|
-
const addItem = (state,[ item ],data) => { return { items : _.concat(state.items ? state.items : [],item) } };
|
|
6
|
-
|
|
7
|
-
Given('I have a {string}',addItem);
|
|
8
|
-
Then('I get a {string}',addItem);
|
|
9
|
-
Then('I have the following items:',(state,params,data) => {
|
|
10
|
-
const items = _.flatten(data);
|
|
11
|
-
expect(state.items).toEqual(items);
|
|
12
|
-
return state;
|
|
13
|
-
});
|
|
14
|
-
Then('I don\'t have a {string}',(state,[ item ],data) => {
|
|
15
|
-
expect(state.items).not.toContain(item);
|
|
16
|
-
return state;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Given('there are {int} cucumbers',(state,[ count ],data) => {
|
|
20
|
-
return _.set('cucumbers',count,state);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
When('I eat {int} cucumbers',(state,[ count ],data) => {
|
|
24
|
-
return _.set('cucumbers',state.cucumbers - count,state);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
Then('I should have {int} cucumbers',(state,[ count ],data) => {
|
|
28
|
-
expect(state.cucumbers).toEqual(count);
|
|
29
|
-
return state;
|
|
30
|
-
});
|