-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assert: Introduce
QUnit.config.countStepsAsOne
Closes #1779.
- Loading branch information
Showing
8 changed files
with
238 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Cherry-picked from 3.0.0, https://github.com/qunitjs/qunit/pull/1775 | ||
QUnit.config.countStepsAsOne = true; | ||
|
||
QUnit.test('passing [once]', function (assert) { | ||
assert.expect(1); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
}); | ||
|
||
QUnit.test('passing [twice]', function (assert) { | ||
assert.expect(2); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
|
||
assert.step('c'); | ||
assert.step('d'); | ||
assert.step('e'); | ||
assert.verifySteps(['c', 'd', 'e']); | ||
}); | ||
|
||
QUnit.test('wrong [a little off]', function (assert) { | ||
assert.expect(2); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
}); | ||
|
||
QUnit.test('wrong [way off]', function (assert) { | ||
assert.expect(5); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
}); | ||
|
||
// These were the correct counts in QUnit 2.x | ||
// https://github.com/qunitjs/qunit/issues/1226 | ||
QUnit.test('previously passing [once]', function (assert) { | ||
assert.expect(4); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
assert.true(true); | ||
}); | ||
|
||
QUnit.test('previously passing [twice]', function (assert) { | ||
assert.expect(9); | ||
|
||
assert.step('a'); | ||
assert.true(true); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
|
||
assert.false(false); | ||
assert.step('c'); | ||
assert.step('d'); | ||
assert.step('e'); | ||
assert.verifySteps(['c', 'd', 'e']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# command: ["qunit", "assert-expect-failure-step.js"] | ||
TAP version 13 | ||
ok 1 passing [once] | ||
ok 2 passing [twice] | ||
not ok 3 wrong [a little off] | ||
--- | ||
message: Expected 2 assertions, but 1 were run | ||
severity: failed | ||
actual : null | ||
expected: undefined | ||
stack: | | ||
at /qunit/test/cli/fixtures/assert-expect-failure-step.js:25:7 | ||
at internal | ||
... | ||
not ok 4 wrong [way off] | ||
--- | ||
message: Expected 5 assertions, but 1 were run | ||
severity: failed | ||
actual : null | ||
expected: undefined | ||
stack: | | ||
at /qunit/test/cli/fixtures/assert-expect-failure-step.js:33:7 | ||
at internal | ||
... | ||
not ok 5 previously passing [once] | ||
--- | ||
message: |+ | ||
Expected 4 assertions, but 2 were run | ||
Remember that with QUnit.config.countStepsAsOne and in QUnit 3.0, steps no longer count as separate assertions. https://qunitjs.com/api/assert/expect/ | ||
severity: failed | ||
actual : null | ||
expected: undefined | ||
stack: | | ||
at /qunit/test/cli/fixtures/assert-expect-failure-step.js:43:7 | ||
at internal | ||
... | ||
not ok 6 previously passing [twice] | ||
--- | ||
message: |+ | ||
Expected 9 assertions, but 4 were run | ||
Remember that with QUnit.config.countStepsAsOne and in QUnit 3.0, steps no longer count as separate assertions. https://qunitjs.com/api/assert/expect/ | ||
severity: failed | ||
actual : null | ||
expected: undefined | ||
stack: | | ||
at /qunit/test/cli/fixtures/assert-expect-failure-step.js:52:7 | ||
at internal | ||
... | ||
1..6 | ||
# pass 2 | ||
# skip 0 | ||
# todo 0 | ||
# fail 4 | ||
|
||
# exit code: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
QUnit.config.requireExpects = true; | ||
|
||
QUnit.test('passing [once]', function (assert) { | ||
assert.expect(3); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
}); | ||
|
||
QUnit.test('passing [twice]', function (assert) { | ||
assert.expect(7); | ||
|
||
assert.step('a'); | ||
assert.step('b'); | ||
assert.verifySteps(['a', 'b']); | ||
|
||
assert.step('c'); | ||
assert.step('d'); | ||
assert.step('e'); | ||
assert.verifySteps(['c', 'd', 'e']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# command: ["qunit", "assert-expect-step-warning.js"] | ||
|
||
TAP version 13 | ||
ok 1 passing [once] | ||
ok 2 passing [twice] | ||
1..2 | ||
# pass 2 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
|
||
# stderr | ||
Counting each assert.step() for assert.expect() is changing in QUnit 3.0. You can enable QUnit.config.countStepsAsOne to prepare for the upgrade. https://qunitjs.com/api/assert/expect/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters