qunitjs / qunit

🔮 An easy-to-use JavaScript unit testing framework.
https://qunitjs.com
MIT License
4.02k stars 783 forks source link

Stack trace cleaning preserves URLs with ports #1769

Closed Krinkle closed 3 weeks ago

Krinkle commented 3 weeks ago

When serving test suites from a URL like localhost:4000/test/index.html, QUnit's stack trace cleaner doesn't work. This falls back gracefully to showing the full stack trace, but we could do better here.

Example from the MediaWiki VisualEditor test suite:

ve.ui.UrlStringTransferHandler.static.matchFunction@http://localhost:4000/load.php/ext.visualEditor.core:55909:2
ve.ce.Surface.prototype.afterPaste@http://localhost:4000/load.php/ext.visualEditor.core:34356:18
ve.test.utils.runSurfacePasteTest@http://localhost:4000/load.php/test.VisualEditor/26712:28
@http://localhost:4000/load.php/test.VisualEditor:29497:8
runTest@http://localhost:4000/resources/lib/qunitjs/qunit.js:2697:35
run@http://localhost:4000/resources/lib/qunitjs/qunit.js:2680:16
queue/runTest/<@http://localhost:4000/resources/lib/qunitjs/qunit.js:2951:16
processTaskQueue@http://localhost:4000/resources/lib/qunitjs/qunit.js:2271:26
processTaskQueue/<@http://localhost:4000/resources/lib/qunitjs/qunit.js:2275:29

This affects both the HTML Reporter and the TAP Reporter (QUnit CLI) alike. It's shared code, exposed via testEnd event data to reporters.

The bottom half should have been trimmed off by the stacktrace cleaner.