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: docs/api/assert/expect.md
+55-46Lines changed: 55 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,54 +26,9 @@ It is recommended to test asynchronous code with the [`assert.verifySteps()`](./
26
26
27
27
## Changelog
28
28
29
+
| [QUnit 2.21.1](https://github.com/qunitjs/qunit/releases/tag/2.21.1) | Warn if `assert.expect()` is used with `assert.verifySteps()`.<br>See also [§ Migration: countStepsAsOne](#migration-countstepsasone).
29
30
| UNRELEASED | `assert.expect()` now counts [`assert.verifySteps()`](./verifySteps.md) as one assertion. Steps no longer count separately.
30
31
31
-
## Migration guide
32
-
33
-
If you use `assert.expect()` in combination with `assert.step()` and [`assert.verifySteps()`](../assert/verifySteps.md) in the same test, you previously counted both the steps and the verification of the steps. In QUnit 3.0 this changes to count `assert.verifySteps()` as one assertion instead ([#1226](https://github.com/qunitjs/qunit/issues/1226)).
34
-
35
-
Before, on QUnit 2.x without [QUnit.config.countStepsAsOne](../config/countStepsAsOne.md):
36
-
37
-
```js
38
-
QUnit.test('example', asyncfunction (assert) {
39
-
assert.expect(6);
40
-
41
-
MyVoice.on('noun', function (word) {
42
-
assert.step(word); // 1, 2, 3, 4
43
-
});
44
-
var song =awaitMyVoice.sing('My Favorite Things', { lines:1 });
45
-
46
-
assert.true(song.finished, 'finished'); // 5
47
-
assert.verifySteps([ // 6
48
-
'Raindrops',
49
-
'roses',
50
-
'whiskers',
51
-
'kittens'
52
-
]);
53
-
});
54
-
```
55
-
56
-
After:
57
-
58
-
```js
59
-
QUnit.test('example', asyncfunction (assert) {
60
-
assert.expect(2);
61
-
62
-
MyVoice.on('noun', function (word) {
63
-
assert.step(word);
64
-
});
65
-
var song =awaitMyVoice.sing('My Favorite Things', { lines:1 });
66
-
67
-
assert.true(song.finished, 'finished'); // 1
68
-
assert.verifySteps([ // 2
69
-
'Raindrops',
70
-
'roses',
71
-
'whiskers',
72
-
'kittens'
73
-
]);
74
-
});
75
-
```
76
-
77
32
## Examples
78
33
79
34
### Example: No assertions
@@ -133,3 +88,57 @@ QUnit.test('example', function (assert) {
If you use `assert.expect()` in combination with `assert.step()` and [`assert.verifySteps()`](../assert/verifySteps.md) in the same test, you previously counted both the steps and the verification as assertions. In QUnit 3.0 this changes to count `assert.verifySteps()` as one assertion instead ([#1226](https://github.com/qunitjs/qunit/issues/1226)).
95
+
96
+
In QUnit 2.21.1 the following warning is introduced:
97
+
98
+
```
99
+
Counting each assert.step() for assert.expect() is changing
100
+
in QUnit 3.0. Omit assert.expect() from tests that use assert.step(),
101
+
or enable QUnit.config.countStepsAsOne to prepare for the upgrade.
102
+
```
103
+
104
+
Before: QUnit 2.x without `QUnit.config.countStepsAsOne`:
105
+
106
+
```js
107
+
QUnit.test('example', asyncfunction (assert) {
108
+
assert.expect(6);
109
+
110
+
MyVoice.on('noun', function (word) {
111
+
assert.step(word); // 1, 2, 3, 4
112
+
});
113
+
var song =awaitMyVoice.sing('My Favorite Things', { lines:1 });
114
+
115
+
assert.true(song.finished, 'finished'); // 5
116
+
assert.verifySteps([ // 6
117
+
'Raindrops',
118
+
'roses',
119
+
'whiskers',
120
+
'kittens'
121
+
]);
122
+
});
123
+
```
124
+
125
+
After: QUnit 2.x with [`QUnit.config.countStepsAsOne`](../config/countStepsAsOne.md) enabled, or on QUnit 3.0:
126
+
127
+
```js
128
+
QUnit.test('example', asyncfunction (assert) {
129
+
assert.expect(2);
130
+
131
+
MyVoice.on('noun', function (word) {
132
+
assert.step(word);
133
+
});
134
+
var song =awaitMyVoice.sing('My Favorite Things', { lines:1 });
0 commit comments