Skip to content

Commit

Permalink
10.1.1: Avoid formatting non-string errors as JSHandle@error
Browse files Browse the repository at this point in the history
Puppeteer still doesn't support postMessage/structuredClone-style
transporting of built-in value types between browser and Node.
  • Loading branch information
Krinkle committed Jul 19, 2024
1 parent 2c58687 commit 5827a3e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v10.1.1:
date: 2024-07-18
changes:
- Fix formatting of non-string errors from `QUnit.on('error')` events.
v10.1.0:
date: 2024-07-18
changes:
Expand Down
16 changes: 16 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ module.exports = function(grunt) {
/Chrome timed out/.test(stdout)) {
cb(err !== null);

// qunit:failOnError
} else if (/test\/qunit_on_error\.html/.test(stdout) &&
stdout.includes('>> Error: boom') &&
/at .*qunit_on_error.html:15/.test(stdout)) {
cb(err !== null);

// qunit:failPageError
} else if (/test\/qunit_page_error\.html/.test(stdout) &&
/ReferenceError: boom is not defined/.test(stdout) &&
Expand Down Expand Up @@ -146,6 +152,9 @@ module.exports = function(grunt) {
failCircularObject: {
command: 'grunt qunit:failCircularObject --with-failing'
},
failOnError: {
command: 'grunt qunit:failOnError --with-failing'
},
failPageError: {
command: 'grunt qunit:failPageError --with-failing'
},
Expand Down Expand Up @@ -179,6 +188,13 @@ module.exports = function(grunt) {
]
}
});
grunt.config.set('qunit.failOnError', {
options: {
urls: [
'http://localhost:9000/test/qunit_on_error.html'
]
}
});
grunt.config.set('qunit.failPageError', {
options: {
urls: [
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# grunt-contrib-qunit v10.1.0 [![Build Status](https://github.com/gruntjs/grunt-contrib-qunit/workflows/Tests/badge.svg)](https://github.com/gruntjs/grunt-contrib-qunit/actions?workflow=Tests)
# grunt-contrib-qunit v10.1.1 [![Build Status](https://github.com/gruntjs/grunt-contrib-qunit/workflows/Tests/badge.svg)](https://github.com/gruntjs/grunt-contrib-qunit/actions?workflow=Tests)

> Run QUnit unit tests in a headless Chrome instance
Expand Down Expand Up @@ -272,6 +272,7 @@ grunt.event.on('qunit.on.testEnd', function (test) {

## Release History

* 2024-07-18   v10.1.1   Fix formatting of non-string errors from `QUnit.on('error')` events.
* 2024-07-18   v10.1.0   Include errors from `QUnit.on('error')` in the output.
* 2024-06-18   v10.0.0   Remove support for delaying qunit.js via RequireJS. AMD continues to be supported for loading source code and tests, but load qunit.js in its own script before RequireJS, and reference QUnit directly. Examples on [qunitjs.com](https://qunitjs.com/api/config/autostart/).
* 2024-06-11   v9.1.1   Remove dependency on `p-each-series` package.
Expand Down
2 changes: 1 addition & 1 deletion chrome/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// https://qunitjs.com/api/callbacks/QUnit.on/

QUnit.on('error', function(error) {
sendMessage('qunit.on.error', error);
sendMessage('qunit.on.error', error.stack || String(error));
});

QUnit.on('testStart', function(obj) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-contrib-qunit",
"description": "Run QUnit unit tests in a headless Chrome instance",
"version": "10.1.0",
"version": "10.1.1",
"author": {
"name": "Grunt Team",
"url": "https://gruntjs.com/"
Expand Down
2 changes: 1 addition & 1 deletion tasks/qunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module.exports = function(grunt) {
// by QUnit plugins.
// https://qunitjs.com/api/extension/QUnit.onUncaughtException/
grunt.log.writeln();
grunt.log.error(err.stack || err);
grunt.log.error(err);
grunt.event.emit('qunit.error.onError', err);
});

Expand Down
25 changes: 25 additions & 0 deletions test/qunit_on_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Suite</title>
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css" media="screen">
<script src="../node_modules/qunit/qunit/qunit.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script>
QUnit.moduleStart(function () {
try {
throw new Error('boom');
} catch (e) {
QUnit.onUncaughtException(e);
}
});
QUnit.test('basic test', function(assert) {
assert.ok(true);
});
</script>
</body>
</html>

0 comments on commit 5827a3e

Please sign in to comment.