vitest-cucumber-plugin 0.5.3 → 0.5.4

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,4 @@
1
+ * v0.5.4 : Added vue test
1
2
  * v0.5.3 : Provide code snippets when a step definition is not found
2
3
  * v0.5.2 : Throw an error if a step file import fails instead of logging it
3
4
  * v0.5.1 : Added info level logging for tracing state through steps. Also added a log file option.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-cucumber-plugin",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Plugin for Vitest which allows for tests to be written in Cucumber format.",
5
5
  "keywords": [
6
6
  "vite",
@@ -0,0 +1,25 @@
1
+ import { Given, When, Then } from 'vitest-cucumber-plugin';
2
+ import Test from '../../src/test.vue';
3
+ import { mount, get } from '../support/components.js';
4
+ import { expect } from 'vitest';
5
+ import _ from 'lodash/fp.js';
6
+
7
+ Given('I have a test component', (state,params,data) => {
8
+ return _.set('test',mount(Test),state);
9
+ });
10
+
11
+ When('I do nothing', (state,params,data) => state);
12
+
13
+ Then('the test component text is {string}', (state,[ text ],data) => {
14
+ const testComponent = get(state.test);
15
+ const textElement = testComponent.get('.text');
16
+ expect(textElement.text()).toBe(text);
17
+ return state;
18
+ });
19
+
20
+ When('I push the button', (state,params,data) => {
21
+ const testComponent = get(state.test);
22
+ const buttonElement = testComponent.get('button');
23
+ buttonElement.trigger('click');
24
+ return state;
25
+ });
@@ -0,0 +1,19 @@
1
+ import * as testUtils from '@vue/test-utils';
2
+ import { v4 as uuid } from 'uuid';
3
+ import _ from 'lodash/fp.js';
4
+
5
+ const components = {};
6
+
7
+ const mount = (vue,options) => {
8
+ const id = uuid();
9
+ const mountOptions = {};
10
+ components[id] = testUtils.mount(vue,mountOptions);
11
+ return { id, options };
12
+ };
13
+
14
+ const get = (component) => components[component.id];
15
+
16
+ export {
17
+ mount,
18
+ get,
19
+ };
@@ -0,0 +1,10 @@
1
+ Feature: Vue component tests example
2
+ Scenario: Initial state
3
+ Given I have a test component
4
+ When I do nothing
5
+ Then the test component text is "Hello World!"
6
+
7
+ Scenario: Button pressed
8
+ Given I have a test component
9
+ When I push the button
10
+ Then the test component text is "Button pressed!"