You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build: Refactor QUnit.start() definition to inject self-reference
Follows-up 05e15ba, which made this into a factory function,
but that has the downside of making the QUnit object not defined in
one object literal, which makes a few other things reasier to reason
about.
In a way, it's more honest to say that start is the product of a
factory function, but I'd prefer to maintain the simplicity of an
uncoupled literal declaration the entire API, in particular in prep
for native ESM export (ref #1551).
I'll accept in return the internal responsiblity to not call start()
"incorrectly" (i.e. before it is ready). This responsibility does not
leak into, complicate, break, or otherwise change the public API, and
is mitigated by a runtime detection, for the benefit of future
contributors and maintainers to QUnit.
thrownewError('QUnit.start cannot be called inside a test.');
50
+
// Create a list of simplified and independent module descriptor objects for
51
+
// the QUnit.begin callbacks. This prevents plugins from relying on reading
52
+
// from (or writing!) to internal state.
53
+
constmodulesLog=[];
54
+
for(leti=0;i<config.modules.length;i++){
55
+
// Always omit the unnamed module from the list of module names
56
+
// for UI plugins, even if there were glboal tests defined.
57
+
if(config.modules[i].name!==''){
58
+
modulesLog.push({
59
+
name: config.modules[i].name,
60
+
moduleId: config.modules[i].moduleId
61
+
});
73
62
}
74
-
if(config._runStarted){
75
-
if(document&&config.autostart){
76
-
thrownewError('QUnit.start() called too many times. Did you call QUnit.start() in browser context when autostart is also enabled? https://qunitjs.com/api/QUnit/start/');
77
-
}
78
-
thrownewError('QUnit.start() called too many times.');
63
+
}
64
+
65
+
// The test run is officially beginning now
66
+
emit('runStart',globalSuiteReport.start(true));
67
+
runLoggingCallbacks('begin',{
68
+
totalTests: Test.count,
69
+
modules: modulesLog
70
+
}).then(unblockAndAdvanceQueue);
71
+
}
72
+
73
+
exportfunctionstart(){
74
+
if(config.current){
75
+
thrownewError('QUnit.start cannot be called inside a test.');
76
+
}
77
+
if(config._runStarted){
78
+
if(document&&config.autostart){
79
+
thrownewError('QUnit.start() called too many times. Did you call QUnit.start() in browser context when autostart is also enabled? https://qunitjs.com/api/QUnit/start/');
79
80
}
81
+
thrownewError('QUnit.start() called too many times.');
82
+
}
80
83
81
-
config._runStarted=true;
84
+
config._runStarted=true;
82
85
83
-
// Add a slight delay to allow definition of more modules and tests.
0 commit comments