Skip to content

Commit

Permalink
Re-introduce qunit.log event
Browse files Browse the repository at this point in the history
* Now as one parameter, matching the QUnit signature, instead of
  spread as positional parameters.
  https://qunitjs.com/api/callbacks/QUnit.log/

* Now with caveats documented in-code, and no longer promoted/recommended
  from the `summaryOnly` option docs.

Ref #207
  • Loading branch information
Krinkle committed Jun 11, 2024
1 parent 4d40eee commit 60d05ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions chrome/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@
sendMessage('qunit.begin');
});

// It is encouraged to listen to `qunit.on.testEnd` instead, so that you
// don't have to deal with:
// * grouping tests by test and module (testName provides "fullName",
// and provides FailedAssertion in one go instead of per-assertion).
// * inversion of "todo" tests (i.e. pass when failing).
// * undefined actual/expected for passing tests.
QUnit.log(function(obj) {
var actual;
var expected;
if (!obj.result) {
// Dumping large objects can be very slow, and the dump isn't used for
// passing tests, so only dump if the test failed.
actual = QUnit.dump.parse(obj.actual);
expected = QUnit.dump.parse(obj.expected);
}
sendMessage('qunit.log', {
result: obj.result,
actual: actual,
expected: expected,
message: obj.message,
source: obj.source,
module: obj.module,
name: obj.name,
todo: obj.todo
});
});

QUnit.done(function() {
sendMessage('qunit.done');
});
Expand Down
1 change: 1 addition & 0 deletions docs/qunit-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ QUnit events are forwarded to Grunt's event system, enabling you to build custom
* `qunit.on.runEnd` `(obj)`

* `qunit.begin`
* `qunit.log` `(obj)`
* `qunit.done`

In addition to forwarding QUnit's events, the following events are also emitted by the Grunt plugin:
Expand Down
2 changes: 1 addition & 1 deletion docs/qunit-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ When true, the whole task will not fail when there are individual test failures,
Type: `boolean`
Default: `false`

When true, this will suppress the default logging for individually failed tests. Customized logging can be performed by listening to and responding to `qunit.log` events.
When true, this will suppress the default logging for individually failed tests. Customized logging can be performed by listening to `qunit.on.testEnd` events.

## puppeteer
Type: `Object`
Expand Down

0 comments on commit 60d05ac

Please sign in to comment.