Skip to content

Commit

Permalink
Core: deprecate QUnit.load
Browse files Browse the repository at this point in the history
Fixes qunitjs#1084
Modularize and export load implementation
The load impl remains as-is
The QUnit.load entry point issues deprecation warning
  • Loading branch information
smcclure15 committed Nov 9, 2020
1 parent c494fb8 commit 594a9e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
6 changes: 3 additions & 3 deletions reporter/html.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QUnit from "../src/core";
import QUnit, { load } from "../src/core";
import Test from "../src/test";
import { extractStacktrace } from "../src/core/stacktrace";
import { now } from "../src/core/utilities";
Expand Down Expand Up @@ -1021,9 +1021,9 @@ export function escapeText( s ) {
} )( window.phantom );

if ( notPhantom && document.readyState === "complete" ) {
QUnit.load();
load();
} else {
addEvent( window, "load", QUnit.load );
addEvent( window, "load", load );
}

// Wrap window.onerror. We will call the original window.onerror to see if
Expand Down
44 changes: 25 additions & 19 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import equiv from "./equiv";
import dump from "./dump";
import module from "./module";
import Assert from "./assert";
import Logger from "./logger";
import Test, { test, skip, only, todo, pushFailure } from "./test";
import exportQUnit from "./export";

Expand Down Expand Up @@ -71,7 +72,7 @@ extend( QUnit, {
// Starts from Node even if .load was not previously called. We still return
// early otherwise we'll wind up "beginning" twice.
if ( !document ) {
QUnit.load();
load();
}

return;
Expand All @@ -92,24 +93,8 @@ extend( QUnit, {
extend: extend,

load: function() {
config.pageLoaded = true;

// Initialize the configuration options
extend( config, {
stats: { all: 0, bad: 0, testCount: 0 },
started: 0,
updateRate: 1000,
autostart: true,
filter: ""
}, true );

if ( !runStarted ) {
config.blocking = false;

if ( config.autostart ) {
scheduleBegin();
}
}
Logger.warn( "QUnit.load is deprecated and will be removed in QUnit 3.0." );
load();
},

stack: function( offset ) {
Expand All @@ -129,6 +114,27 @@ QUnit.dump = dump;

registerLoggingCallbacks( QUnit );

export function load() {
config.pageLoaded = true;

// Initialize the configuration options
extend( config, {
stats: { all: 0, bad: 0, testCount: 0 },
started: 0,
updateRate: 1000,
autostart: true,
filter: ""
}, true );

if ( !runStarted ) {
config.blocking = false;

if ( config.autostart ) {
scheduleBegin();
}
}
}

function scheduleBegin() {

runStarted = true;
Expand Down

0 comments on commit 594a9e5

Please sign in to comment.