Skip to content

Commit aa4a9db

Browse files
committed
Remove support for delaying qunit.js via AMD
The current check in bridge.js is problematic because if a project includes RequireJS anywhere, for any purpose, the bridge crashes unless RequireJS is also in charge of loading QUnit. QUnit 3.0 will remove support for its built-in AMD export (ref qunitjs/qunit#1729). It remains supported to use AMD/RequireJS in your HTML file, and to use it to load source code and/or test files. However, it is no longer supported to delay the loading of qunit.js itself via AMD. In order to make that use possible in QUnit 3.0, the bridge.js must stop assuming that presence of define.amd implies using it to load QUnit itself. Example at https://qunitjs.com/api/config/autostart/#loading-with-requirejs
1 parent 3f623aa commit aa4a9db

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

chrome/bridge.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@
77
*/
88

99
/* global QUnit:true */
10-
(function (factory) {
10+
(function() {
11+
'use strict';
12+
1113
if (window.self !== window.top) {
1214
// Ignore iframes. https://github.com/gruntjs/grunt-contrib-qunit/issues/202
1315
return;
1416
}
15-
if (typeof define === 'function' && define.amd) {
16-
require(['qunit'], factory);
17-
} else {
18-
factory(QUnit);
19-
}
20-
}(function(QUnit) {
21-
'use strict';
2217

2318
var lastMessage = performance.now();
2419

@@ -137,4 +132,4 @@
137132
QUnit.done(function() {
138133
sendMessage('qunit.done');
139134
});
140-
}));
135+
}());

docs/qunit-examples.md

-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ grunt.initConfig({
9494
});
9595
```
9696

97-
## Loading QUnit with AMD
98-
When using AMD to load QUnit and your tests, make sure to have a path for the `qunit` module defined.
99-
10097
## Events and reporting
10198
QUnit events are forwarded to Grunt's event system, enabling you to build custom reporting tools. Please refer to the QUnit API documentation on [QUnit events](https://qunitjs.com/api/callbacks/QUnit.on/) and [QUnit callbacks](https://qunitjs.com/api/callbacks/) for when and what data is exposed from these events.
10299

0 commit comments

Comments
 (0)