Skip to content

Commit f8c1b64

Browse files
committed
Docs: Move migration guide down on assert.expect() page
It was a bit too prominent, making it seem like it might be about the method in general rather than just when used with `assert.step()`.
1 parent c9eb69d commit f8c1b64

File tree

3 files changed

+57
-48
lines changed

3 files changed

+57
-48
lines changed

docs/api/assert/expect.md

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,9 @@ It is recommended to test asynchronous code with the [`assert.verifySteps()`](./
2626

2727
## Changelog
2828

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).
2930
| UNRELEASED | `assert.expect()` now counts [`assert.verifySteps()`](./verifySteps.md) as one assertion. Steps no longer count separately.
3031

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', async function (assert) {
39-
assert.expect(6);
40-
41-
MyVoice.on('noun', function (word) {
42-
assert.step(word); // 1, 2, 3, 4
43-
});
44-
var song = await MyVoice.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', async function (assert) {
60-
assert.expect(2);
61-
62-
MyVoice.on('noun', function (word) {
63-
assert.step(word);
64-
});
65-
var song = await MyVoice.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-
7732
## Examples
7833

7934
### Example: No assertions
@@ -133,3 +88,57 @@ QUnit.test('example', function (assert) {
13388
assert.strictEqual(result, 4, '2 squared equals 4');
13489
});
13590
```
91+
92+
## Migration: countStepsAsOne
93+
94+
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', async function (assert) {
108+
assert.expect(6);
109+
110+
MyVoice.on('noun', function (word) {
111+
assert.step(word); // 1, 2, 3, 4
112+
});
113+
var song = await MyVoice.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', async function (assert) {
129+
assert.expect(2);
130+
131+
MyVoice.on('noun', function (word) {
132+
assert.step(word);
133+
});
134+
var song = await MyVoice.sing('My Favorite Things', { lines: 1 });
135+
136+
assert.true(song.finished, 'finished'); // 1
137+
assert.verifySteps([ // 2
138+
'Raindrops',
139+
'roses',
140+
'whiskers',
141+
'kittens'
142+
]);
143+
});
144+
```

docs/api/assert/step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The Step API provides an easy way to verify execution logic to a high degree of
2323

2424
## Changelog
2525

26-
| UNRELEASED | [assert.expect()](./expect.md) now counts [assert.verifySteps()](./verifySteps.md) as one assertion. Steps no longer count separately.
26+
| UNRELEASED | [assert.expect()](./expect.md) now counts `assert.verifySteps()` as one assertion. Steps no longer count separately.
2727

2828
## Examples
2929

docs/api/config/countStepsAsOne.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ in QUnit 3.0. Omit assert.expect() from tests that use assert.step(),
3030
or enable QUnit.config.countStepsAsOne to prepare for the upgrade.
3131
```
3232

33-
Refer to [assert.expect(): Migration guide](../assert/expect.md#migration-guide) for before and after examples.
33+
Refer to [assert.expect(): Migration guide](../assert/expect.md#migration-countstepsasone) for before and after examples.

0 commit comments

Comments
 (0)