@g_package/jest-cucumber-fusion 1.0.0

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.
Files changed (36) hide show
  1. package/.prettierignore +16 -0
  2. package/.prettierrc.json +0 -0
  3. package/LICENSE +201 -0
  4. package/README.md +165 -0
  5. package/codecov +0 -0
  6. package/codecov.SHA256SUM +1 -0
  7. package/codecov.SHA256SUM.sig +16 -0
  8. package/docs/AdditionalConfiguration.md +155 -0
  9. package/docs/GherkinTables.md +61 -0
  10. package/docs/Language.md +76 -0
  11. package/docs/ReusingStepDefinitions.md +110 -0
  12. package/docs/RunningTheExamples.md +16 -0
  13. package/docs/ScenarioOutlines.md +43 -0
  14. package/docs/StepDefinitionArguments.md +37 -0
  15. package/package.json +82 -0
  16. package/src/index.d.ts +25 -0
  17. package/src/index.js +404 -0
  18. package/test/specs/features/basic-scenarios.feature +28 -0
  19. package/test/specs/features/language.feature +41 -0
  20. package/test/specs/features/reuse-definition.feature +13 -0
  21. package/test/specs/features/scenario-outline2.feature +71 -0
  22. package/test/specs/features/scenario-outlines.feature +88 -0
  23. package/test/specs/features/step-definitions/basic-scenarios.steps.js +45 -0
  24. package/test/specs/features/step-definitions/language.steps.js +86 -0
  25. package/test/specs/features/step-definitions/reuse-code.js +17 -0
  26. package/test/specs/features/step-definitions/reuse-definition.steps.js +22 -0
  27. package/test/specs/features/step-definitions/scenario-outline2.steps.js +46 -0
  28. package/test/specs/features/step-definitions/scenario-outlines.steps.js +110 -0
  29. package/test/specs/features/step-definitions/using-dynamic-values.steps.js +70 -0
  30. package/test/specs/features/step-definitions/using-gherkin-tables.steps.js +42 -0
  31. package/test/specs/features/using-dynamic-values.feature +34 -0
  32. package/test/specs/features/using-gherkin-tables.feature +16 -0
  33. package/test/src/bank-account.js +17 -0
  34. package/test/src/online-sales.js +33 -0
  35. package/test/src/rocket.js +13 -0
  36. package/test/src/todo-list.js +20 -0
@@ -0,0 +1,16 @@
1
+ # Ignore artifacts:
2
+ .git
3
+ .github
4
+ build
5
+ coverage
6
+ docs
7
+ node_modules
8
+
9
+ .gitignore
10
+ .npmignore
11
+ .prettierignore
12
+ .prettierrc.json
13
+ LICENSE
14
+ package.json
15
+ package-lock.json
16
+ README.md
File without changes
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # Jest Cucumber Fusion
2
+
3
+ Write 'pure' cucumber test in Jest without syntax clutter
4
+
5
+ [![Build Status](https://github.com/b-yond-infinite-network/jest-cucumber-fusion/workflows/Continuous%20Integration/badge.svg)](https://github.com/b-yond-infinite-network/jest-cucumber-fusion/actions?query=workflow%3AIntegration)
6
+ [![Codecov](https://codecov.io/gh/b-yond-infinite-network/jest-cucumber-fusion/branch/master/graph/badge.svg)](https://codecov.io/gh/b-yond-infinite-network/jest-cucumber-fusion)
7
+ [![Publish](https://github.com/b-yond-infinite-network/jest-cucumber-fusion/workflows/Publish/badge.svg)](https://github.com/b-yond-infinite-network/jest-cucumber-fusion/actions?query=workflow%3APublish)
8
+
9
+ [![npm downloads](https://img.shields.io/npm/dm/jest-cucumber-fusion)](https://www.npmjs.com/package/jest-cucumber-fusion)
10
+ [![npm latest](https://img.shields.io/npm/v/jest-cucumber-fusion/latest.svg)](https://www.npmjs.com/package/jest-cucumber-fusion)
11
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
12
+
13
+
14
+ ## Overview
15
+ Build on top of [Jest-cucumber](https://github.com/bencompton/jest-cucumber), Jest-Cucumber-Fusion handle the writing of the corresponding Jest test steps using an uncluttered cucumber style.
16
+ Instead of using `describe` and `it` blocks, you instead write a Jest test for each scenario, and then define `Given`, `When`, and `Then` step definitions inside of your Jest tests.
17
+ Jest-Cucumber-Fusion then allows you to link these Cucumber tests to your javascript Cucumber feature steps.
18
+ Adding a `Fusion`call, the links between your Feature definition and your Steps definition is handled automatically and the necessary scaffolding for jest-cucumber is build behind the scene.
19
+ Now use jest naturally in your project like you would use the native Cucumber library.
20
+
21
+ ## Motivation
22
+
23
+ Jest-cucumber is an amazing project but forces you to write a lot of repetitive scaffolding code to setup the link betwen Jest and Cucumber.
24
+ With Jest-Cucumber-Fusion, it really takes only the minimal code possible:
25
+ - a Cucumber Feature file with gherkin sentences
26
+ - a Cucumber Step definition file with your javascript validation code, ended with the `Fusion` function to link the two
27
+
28
+
29
+
30
+ ## Getting Started
31
+
32
+ ### Install Jest Cucumber Fusion:
33
+
34
+ ```
35
+ npm install jest-cucumber-fusion --save-dev
36
+ ```
37
+
38
+ ### Add a Feature file:
39
+
40
+ ```gherkin
41
+ ###filename: rocket-launching.feature
42
+ Feature: Rocket Launching
43
+
44
+ Scenario: Launching a SpaceX rocket
45
+ Given I am Elon Musk attempting to launch a rocket into space
46
+ When I launch the rocket
47
+ Then the rocket should end up in space
48
+ And the booster(s) should land back on the launch pad
49
+ And nobody should doubt me ever again
50
+ ```
51
+
52
+ ### Add the following to your package.json configuration:
53
+
54
+ ```javascript
55
+ "jest": { "testMatch": [ "**/*.steps.js" ] }
56
+ ```
57
+
58
+
59
+ ### Add a your Cucumber Step definition file and load Fusion
60
+ ```javascript
61
+ //filename: rocket-launching.steps.js
62
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
63
+
64
+ ```
65
+
66
+ ### Load any dependency you need to do your test
67
+
68
+ ```javascript
69
+ //filename: rocket-launching.steps.js
70
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
71
+
72
+ const { Rocket } = require( '../../src/rocket' )
73
+ let rocket
74
+
75
+ ```
76
+
77
+ ### Add steps definitions:
78
+
79
+ ```javascript
80
+ //filename: rocket-launching.steps.js
81
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
82
+
83
+ const { Rocket } = require( '../../src/rocket' )
84
+ let rocket
85
+
86
+ Given( 'I am Elon Musk attempting to launch a rocket into space', () => {
87
+ rocket = new Rocket()
88
+ } )
89
+
90
+ When( 'I launch the rocket', () => {
91
+ rocket.launch()
92
+ } )
93
+
94
+ Then( 'the rocket should end up in space', () => {
95
+ expect(rocket.isInSpace).toBe(true)
96
+ } )
97
+
98
+ And( /^the booster\(s\) should land back on the launch pad$/, () => {
99
+ expect(rocket.boostersLanded).toBe(true)
100
+ } )
101
+
102
+ But( 'nobody should doubt me ever again', () => {
103
+ expect('people').not.toBe('haters')
104
+ } )
105
+ ```
106
+
107
+ ### Adding the Fusion() call at the end of the Step definition file
108
+ You have to match it with your Cucumber Feature definition file:
109
+ ```javascript
110
+ //filename: rocket-launching.steps.js
111
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
112
+
113
+ const { Rocket } = require( '../../src/rocket' )
114
+ let rocket
115
+
116
+ Given( 'I am Elon Musk attempting to launch a rocket into space', () => {
117
+ rocket = new Rocket()
118
+ } )
119
+
120
+ When( 'I launch the rocket', () => {
121
+ rocket.launch()
122
+ } )
123
+
124
+ Then( 'the rocket should end up in space', () => {
125
+ expect(rocket.isInSpace).toBe(true)
126
+ } )
127
+
128
+ And( /^the booster\(s\) should land back on the launch pad$/, () => {
129
+ expect(rocket.boostersLanded).toBe(true)
130
+ } )
131
+
132
+ But( 'nobody should doubt me ever again', () => {
133
+ expect('people').not.toBe('haters')
134
+ } )
135
+
136
+
137
+ Fusion( 'rocket-launching.feature' )
138
+ ```
139
+
140
+ ## Adding coverage
141
+ Since we're using jest, it is very easy to generate the code coverage of your Cucumber test:
142
+ ```javascript
143
+ "jest": {
144
+ "testMatch": [
145
+ "**/*.steps.js"
146
+ ],
147
+ "coveragePathIgnorePatterns": [
148
+ "/node_modules/",
149
+ "/test/"
150
+ ],
151
+ "coverageDirectory": "./coverage/",
152
+ "collectCoverage": true
153
+ }
154
+ ```
155
+
156
+
157
+ ## Additional Documentation
158
+
159
+ * [Gherkin tables](./docs/GherkinTables.md)
160
+ * [Step definition arguments](./docs/StepDefinitionArguments.md)
161
+ * [Scenario outlines](./docs/ScenarioOutlines.md)
162
+ * [Re-using step definitions](./docs/ReusingStepDefinitions.md)
163
+ * [Configuration options](./docs/AdditionalConfiguration.md)
164
+ * [Running the examples](./docs/RunningTheExamples.md)
165
+ * [Language](./docs/Language.md)
package/codecov ADDED
Binary file
@@ -0,0 +1 @@
1
+ 28641437b42ff7296a1ff494cfa9441a0b19902016218b0926b55870ee533a54 codecov
@@ -0,0 +1,16 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+
3
+ iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmpOv5sACgkQgGuyiu13
4
+ mGnmcg/+MYVRFlzf4Y9D81qxf82xfWuzJhcEY0cUqCdCB98p1nwVIAqTshRCWPLn
5
+ bhosCZFAsUp2HrIxseiddcnu/q57S3ARhz/jxxTtr5Z6mezFsdQ7rUZlky9n9Jm7
6
+ 4WT5+XWpQsjLvVWBW5JQ/xQOkszmKvdyyDTtlsqCvGrObUuThjMkGIupImCgFk4Z
7
+ zRAkJ/W3MHJLl+SDVvYqh+dwh9POJlUs6dsV7LNAztmV3Dg4w8SDc4WHrm/VVh5y
8
+ nSzCk2c8DeGJN5pe+uH02EvG81xdYVurLsit/Z5DWGlNbWzy54Uo7UAVgQGxDvGo
9
+ YEag/k85BJJiTFDw67n5ITIQsj908T5VNvQPTGyg5LEnZyGDbbPDCYNdWeikTow7
10
+ Fl2dhpJ+lTgF+bp5Z25KS0lrzcVeO5G0zZSYKSjvB3KgU/oAjw+cLX+LtHjE6AAZ
11
+ guXMyCQ2FJ73KegSSIBAg91S5DBz9zrLlhgzvdRqd0JuiSM/+0GGQ/+HVxwAntVB
12
+ uCbKvZLigHpJfxDz1wIQ3cdhds4/Jxh4T+7s+wPFJplqBq09i8vZv7czLAu/47o4
13
+ SlXWZKWqwPm2q3Vmm3v5dIrHXO8ixnZB5wHeGv1Od4q78GKBbCyOJISVYy0rDwRu
14
+ gG6Uy2BgytqP81NPbnoyNI4U8KD2pDEWRpeywH2SSWWHVq4s578=
15
+ =8mH/
16
+ -----END PGP SIGNATURE-----
@@ -0,0 +1,155 @@
1
+ # Configuration Options
2
+
3
+ ## Disabling scenario / step definition validation
4
+
5
+ Cucumber's approach is to start with your feature file and execute the step definitions in the order defined in the feature file. In contrast, jest-cucumber scenarios are merely Jest tests. In order to provide the same ability as Cucumber to keep the feature files and step definitions in sync, jest-cucumber validates your step definitions against the feature file.
6
+
7
+ By default, this step definition / feature file validation is enabled. If you have scenarios that are defined in the feature file, but not in your step definitions for that feature file, jest-cucumber will raise an error (and provide starter code). If you have scenarios defined in your step definitions for that aren't in your feature file, jest-cucumber will also raise an error. Additionally, jest-cucumber also validates that the steps you define within your scenarios match the steps that are defined in the feature file, and are in the same order.
8
+
9
+ If you would prefer not to have more control over what validation occurs the following options are available:
10
+
11
+ ```javascript
12
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
13
+
14
+
15
+ //your javascript tests
16
+ //....
17
+ //Given( ...
18
+ //
19
+
20
+
21
+ Fusion( 'rocket-launching.feature', {
22
+ errors: {
23
+ missingScenarioInStepDefinitions: true, // Error when a scenario is in the feature file, but not in the step definition
24
+ missingStepInStepDefinitions: true, // Error when a step is in the feature file, but not in the step definitions
25
+ missingScenarioInFeature: true, // Error when a scenario is in the step definitions, but not in the feature
26
+ missingStepInFeature: true, // Error when a step is in the step definitions, but not in the feature
27
+ }
28
+ } )
29
+ ```
30
+
31
+ ## Tag filtering
32
+
33
+ You can specify a tag filter. Tag filters will cause any scenario that is filtered out via a tag filter to be skipped.
34
+
35
+ For example, consider the following feature file:
36
+
37
+ ```gherkin
38
+ Feature: Tagged scenarios
39
+
40
+ @included
41
+ Scenario: Tagged scenario that is included
42
+ Given my scenario has a tag that is included in my jest-cucumber step definitions tag filter
43
+ But I don't have that scenario defined in my step definitions
44
+ When I execute my jest-cucumber scenarios
45
+ Then jest-cucumber should show me an error
46
+
47
+ @excluded
48
+ Scenario: Tagged scenario that is not included
49
+ Given my scenario has a tag that is NOT included in my jest-cucumber step definitions tag filter
50
+ But I don't have that scenario defined in my step definitions
51
+ When I execute my jest-cucumber scenarios
52
+ Then jest-cucumber should NOT show me an error
53
+ ```
54
+
55
+ Consider the following step definitions file:
56
+
57
+ ```javascript
58
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
59
+
60
+
61
+ //your javascript tests
62
+ //....
63
+ //Given( ...
64
+ //
65
+
66
+
67
+ Fusion( 'rocket-launching.feature', { tagFilter: '@included and not @excluded' } )
68
+ ```
69
+
70
+ In this case, the scenario tagged `@included` will be run, and the scenario tagged `@excluded` will be skipped. The tag filtering expressions are very powerful and can include `not`, `and`, `or`, as well as parenthesis.
71
+
72
+ ## Scenario title templates
73
+
74
+ In some cases, having more control over the scenario titles is desired. For example, imagine scenarios that are tagged with with issue ids like so:
75
+
76
+ ```
77
+ Feature: Tagged scenarios
78
+
79
+ @issue-1234
80
+ Scenario: Scenario tagged with issue
81
+ ...
82
+ ...
83
+ ...
84
+ ```
85
+
86
+ Use a `scenarioNameTemplate` function to be provided to generate the scenario title as desired. For example:
87
+
88
+ ```javascript
89
+ const { Given, When, Then, And, But, Fusion } = require( 'jest-cucumber-fusion' )
90
+
91
+
92
+ //your javascript tests
93
+ //....
94
+ //Given( ...
95
+ //
96
+
97
+
98
+ Fusion( 'rocket-launching.feature', {
99
+ scenarioNameTemplate: (vars) => {
100
+ return `${vars.scenarioTitle} (${vars.scenarioTags.join(',')})`
101
+ }
102
+ } )
103
+ ```
104
+
105
+ The output scenario title in this case would be `Scenario tagged with issue (issue-1234)`.
106
+
107
+ The following info is available in the `vars` argument:
108
+
109
+ * `featureTitle` - string
110
+ * `featureTags` - string[]
111
+ * `scenarioTitle` - string
112
+ * `scenarioTags` - string[]
113
+
114
+ ## Relative feature file paths
115
+
116
+ It might feel more natural to load feature files with paths relative to the file loading the feature, instead of relative to the project root. This is possible with help of the `loadRelativePath` flag:
117
+
118
+ ```javascript
119
+ Fusion( 'rocket-launching.feature', { loadRelativePath: true } )
120
+ ```
121
+
122
+ Please note that the path will be relative to the file that calls `Fusion`, so if you use helper files which call `Fusion` for you this might lead to unexpected results.
123
+ Like all other flags you can set the flag globally to always use relative imports.
124
+
125
+ ## Global configuration
126
+
127
+ To avoid repeating the same configuration settings in every step definition file, it is also possible to specify configuration parameters globally. Note that configuration settings specified in step definition files take precedence over global configuration.
128
+
129
+ To enable global configuration, you have to use the jest-cucumber global configuration.
130
+ First specify a configuration JavaScript file in your the `setupFiles` section of your Jest configuration like so:
131
+
132
+ ```javascript
133
+ {
134
+ ...
135
+ "setupFiles": [
136
+ "./jest-cucumber-config"
137
+ ],
138
+ ...
139
+ }
140
+ ```
141
+
142
+ And setup the configuration JavaScript file, like so:
143
+
144
+ ```javascript
145
+ //jest-cucumber-config.js
146
+
147
+ const setJestCucumberConfiguration = require('jest-cucumber').setJestCucumberConfiguration;
148
+
149
+ setJestCucumberConfiguration({
150
+ tagFilter: '@ui and not @slow',
151
+ scenarioNameTemplate: (vars) => {
152
+ return ` ${vars.featureTitle} - ${vars.scenarioTitle}}`;
153
+ }
154
+ });
155
+ ```
@@ -0,0 +1,61 @@
1
+ # Gherkin tables
2
+
3
+ ```gherkin
4
+ Feature: Todo List
5
+
6
+ Scenario: Adding an item to my todo list
7
+ Given my todo list currently looks as follows:
8
+ | TaskName | Priority |
9
+ | Fix bugs in my code | medium |
10
+ | Document my hours | medium |
11
+ When I add the following task:
12
+ | TaskName | Priority |
13
+ | Watch cat videos on YouTube all day | high |
14
+ Then I should see the following todo list:
15
+ | TaskName | Priority |
16
+ | Watch cat videos on YouTube all day | high |
17
+ | Sign up for unemployment | high |
18
+ ```
19
+
20
+ ```javascript
21
+ const { Before, After, Given, When, Then, Fusion } = require( 'jest-cucumber-fusion' )
22
+
23
+ const { TodoList } = require( '../../src/todo-list' )
24
+ let todoList
25
+
26
+
27
+ Before( () => { todoList = new TodoList(); } )
28
+
29
+ Given( 'my todo list currently looks as follows:', table => {
30
+ table.forEach(row => {
31
+ todoList.add( {
32
+ name: row.TaskName,
33
+ priority: row.Priority
34
+ } )
35
+ } )
36
+ } )
37
+
38
+ When( 'I add the following task:', table => {
39
+ todoList.add({
40
+ name: table[0].TaskName,
41
+ priority: table[0].Priority
42
+ })
43
+ })
44
+
45
+ Then( 'I should see the following todo list:', table => {
46
+ expect(todoList.items.length).toBe(table.length)
47
+
48
+ table.forEach((row, index) => {
49
+ expect(todoList.items[index].name).toBe(table[index].TaskName)
50
+ expect(todoList.items[index].priority).toBe(table[index].Priority)
51
+ } )
52
+ } )
53
+
54
+ After( () => {
55
+ const emptyTodo = new TodoList()
56
+ emptyTodo.add( { name: 'Empty on purpose', priority: 'so low' } )
57
+ } )
58
+
59
+
60
+ Fusion( '../features/using-gherkin-tables.feature' )
61
+ ```