You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,23 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
6
6
7
7
* cucumber now waits for the event loop to drain before exiting. To exit immediately when the tests finish running use `--exit`. Use of this flag is discouraged. See [here](/docs/cli.md#exiting) for more information
8
8
9
+
#### Deprecations
10
+
11
+
*`defineSupportCode` is deprecated. Require/import the individual methods instead
Copy file name to clipboardExpand all lines: docs/support_files/hooks.md
+54-62Lines changed: 54 additions & 62 deletions
Original file line number
Diff line number
Diff line change
@@ -3,32 +3,30 @@
3
3
Hooks are used for setup and teardown the environment before and after each scenario. See the [API reference](./api_reference.md) for the specification of the first argument passed to hooks. Multiple *Before* hooks are executed in the order that they were defined. Multiple *After* hooks are executed in the **reverse** order that they were defined.
Hooks can be conditionally selected for execution based on the tags of the scenario.
38
36
39
37
```javascript
40
-
var {defineSupportCode} =require('cucumber');
38
+
var {After, Before} =require('cucumber');
41
39
42
-
defineSupportCode(function({After, Before}) {
43
-
Before(function () {
44
-
// This hook will be executed before all scenarios
45
-
});
40
+
Before(function () {
41
+
// This hook will be executed before all scenarios
42
+
});
46
43
47
-
Before({tags:"@foo"}, function () {
48
-
// This hook will be executed before scenarios tagged with @foo
49
-
});
44
+
Before({tags:"@foo"}, function () {
45
+
// This hook will be executed before scenarios tagged with @foo
46
+
});
50
47
51
-
Before({tags:"@foo and @bar"}, function () {
52
-
// This hook will be executed before scenarios tagged with @foo and @bar
53
-
});
48
+
Before({tags:"@foo and @bar"}, function () {
49
+
// This hook will be executed before scenarios tagged with @foo and @bar
50
+
});
54
51
55
-
Before({tags:"@foo or @bar"}, function () {
56
-
// This hook will be executed before scenarios tagged with @foo or @bar
57
-
});
52
+
Before({tags:"@foo or @bar"}, function () {
53
+
// This hook will be executed before scenarios tagged with @foo or @bar
54
+
});
58
55
59
-
// You can use the following shorthand when only specifying tags
60
-
Before("@foo", function () {
61
-
// This hook will be executed before scenarios tagged with @foo
62
-
});
56
+
// You can use the following shorthand when only specifying tags
57
+
Before("@foo", function () {
58
+
// This hook will be executed before scenarios tagged with @foo
63
59
});
64
60
```
65
61
@@ -72,12 +68,10 @@ If you need to imperatively skip a test using a `Before` hook, this can be done
72
68
This includes using: a synchronous return, an asynchronous callback, or an asynchronous promise
73
69
74
70
```javascript
75
-
defineSupportCode(({After, Before}) => {
76
-
// Synchronous
77
-
Before(function() {
78
-
// perform some runtime check to decide whether to skip the proceeding scenario
79
-
return'skipped'
80
-
});
71
+
// Synchronous
72
+
Before(function() {
73
+
// perform some runtime check to decide whether to skip the proceeding scenario
74
+
return'skipped'
81
75
});
82
76
```
83
77
@@ -88,25 +82,23 @@ If you have some setup / teardown that needs to be done before or after all scen
88
82
Unlike `Before` / `After` these methods will not have a world instance as `this`. This is becauce each scenario gets its own world instance and these hooks run before / after **all** scenarios.
0 commit comments