From 5827a3e401491d31a4cd11428f9e01f727c9feca Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 19 Jul 2024 03:52:50 +0100 Subject: [PATCH] 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. --- CHANGELOG | 4 ++++ Gruntfile.js | 16 ++++++++++++++++ README.md | 3 ++- chrome/bridge.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- tasks/qunit.js | 2 +- test/qunit_on_error.html | 25 +++++++++++++++++++++++++ 8 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 test/qunit_on_error.html diff --git a/CHANGELOG b/CHANGELOG index 0702f5d..d437885 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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: diff --git a/Gruntfile.js b/Gruntfile.js index c972735..683ea90 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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) && @@ -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' }, @@ -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: [ diff --git a/README.md b/README.md index 661da59..29d726f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/chrome/bridge.js b/chrome/bridge.js index 9f78336..c9f41f6 100644 --- a/chrome/bridge.js +++ b/chrome/bridge.js @@ -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) { diff --git a/package-lock.json b/package-lock.json index f3023db..1cf6a4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "grunt-contrib-qunit", - "version": "10.1.0", + "version": "10.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "grunt-contrib-qunit", - "version": "10.1.0", + "version": "10.1.1", "license": "MIT", "dependencies": { "eventemitter2": "^6.4.9", diff --git a/package.json b/package.json index 83ac85a..6682c21 100644 --- a/package.json +++ b/package.json @@ -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/" diff --git a/tasks/qunit.js b/tasks/qunit.js index ddc5dbf..f075ef7 100644 --- a/tasks/qunit.js +++ b/tasks/qunit.js @@ -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); }); diff --git a/test/qunit_on_error.html b/test/qunit_on_error.html new file mode 100644 index 0000000..dc03018 --- /dev/null +++ b/test/qunit_on_error.html @@ -0,0 +1,25 @@ + + + + + Test Suite + + + + +
+
+ + +