Skip to content

Commit 5827a3e

Browse files
committed
10.1.1: Avoid formatting non-string errors as JSHandle@error
Puppeteer still doesn't support postMessage/structuredClone-style transporting of built-in value types between browser and Node.
1 parent 2c58687 commit 5827a3e

8 files changed

+52
-6
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v10.1.1:
2+
date: 2024-07-18
3+
changes:
4+
- Fix formatting of non-string errors from `QUnit.on('error')` events.
15
v10.1.0:
26
date: 2024-07-18
37
changes:

Gruntfile.js

+16
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ module.exports = function(grunt) {
110110
/Chrome timed out/.test(stdout)) {
111111
cb(err !== null);
112112

113+
// qunit:failOnError
114+
} else if (/test\/qunit_on_error\.html/.test(stdout) &&
115+
stdout.includes('>> Error: boom') &&
116+
/at .*qunit_on_error.html:15/.test(stdout)) {
117+
cb(err !== null);
118+
113119
// qunit:failPageError
114120
} else if (/test\/qunit_page_error\.html/.test(stdout) &&
115121
/ReferenceError: boom is not defined/.test(stdout) &&
@@ -146,6 +152,9 @@ module.exports = function(grunt) {
146152
failCircularObject: {
147153
command: 'grunt qunit:failCircularObject --with-failing'
148154
},
155+
failOnError: {
156+
command: 'grunt qunit:failOnError --with-failing'
157+
},
149158
failPageError: {
150159
command: 'grunt qunit:failPageError --with-failing'
151160
},
@@ -179,6 +188,13 @@ module.exports = function(grunt) {
179188
]
180189
}
181190
});
191+
grunt.config.set('qunit.failOnError', {
192+
options: {
193+
urls: [
194+
'http://localhost:9000/test/qunit_on_error.html'
195+
]
196+
}
197+
});
182198
grunt.config.set('qunit.failPageError', {
183199
options: {
184200
urls: [

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 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)
1+
# 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)
22

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

273273
## Release History
274274

275+
* 2024-07-18   v10.1.1   Fix formatting of non-string errors from `QUnit.on('error')` events.
275276
* 2024-07-18   v10.1.0   Include errors from `QUnit.on('error')` in the output.
276277
* 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/).
277278
* 2024-06-11   v9.1.1   Remove dependency on `p-each-series` package.

chrome/bridge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// https://qunitjs.com/api/callbacks/QUnit.on/
4242

4343
QUnit.on('error', function(error) {
44-
sendMessage('qunit.on.error', error);
44+
sendMessage('qunit.on.error', error.stack || String(error));
4545
});
4646

4747
QUnit.on('testStart', function(obj) {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "grunt-contrib-qunit",
33
"description": "Run QUnit unit tests in a headless Chrome instance",
4-
"version": "10.1.0",
4+
"version": "10.1.1",
55
"author": {
66
"name": "Grunt Team",
77
"url": "https://gruntjs.com/"

tasks/qunit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ module.exports = function(grunt) {
246246
// by QUnit plugins.
247247
// https://qunitjs.com/api/extension/QUnit.onUncaughtException/
248248
grunt.log.writeln();
249-
grunt.log.error(err.stack || err);
249+
grunt.log.error(err);
250250
grunt.event.emit('qunit.error.onError', err);
251251
});
252252

test/qunit_on_error.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Test Suite</title>
6+
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css" media="screen">
7+
<script src="../node_modules/qunit/qunit/qunit.js"></script>
8+
</head>
9+
<body>
10+
<div id="qunit"></div>
11+
<div id="qunit-fixture"></div>
12+
<script>
13+
QUnit.moduleStart(function () {
14+
try {
15+
throw new Error('boom');
16+
} catch (e) {
17+
QUnit.onUncaughtException(e);
18+
}
19+
});
20+
QUnit.test('basic test', function(assert) {
21+
assert.ok(true);
22+
});
23+
</script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)