Skip to content

Commit

Permalink
Resolve deprecation warnings for Jasmine
Browse files Browse the repository at this point in the history
Jasmine recommends to use the `configure` method on the environment
during boot. This commit makes the code correspond to how it's done in
Jasmine's default boot file. The options dropdown in the HTML reporter
now works again after these changes, because this broke in the upgrade
to Jasmine 3, and the unit tests are executed in a random order by
default, which is important to make sure the unit tests are
self-contained and don't depend on the result of another unit test.
  • Loading branch information
timvandermeij committed Nov 17, 2018
1 parent fd3b780 commit 016c276
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
33 changes: 14 additions & 19 deletions test/font/jasmine-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,27 @@ function initializePDFJS(callback) {
},
});

var stoppingOnSpecFailure = queryString.getParam('failFast');
env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ?
false : stoppingOnSpecFailure);

var throwingExpectationFailures = queryString.getParam('throwFailures');
env.throwOnExpectationFailure(throwingExpectationFailures);
var config = {
failFast: queryString.getParam('failFast'),
oneFailurePerSpec: queryString.getParam('oneFailurePerSpec'),
hideDisabled: queryString.getParam('hideDisabled'),
};

var random = queryString.getParam('random');
env.randomizeTests(random);
if (random !== undefined && random !== '') {
config.random = random;
}

var seed = queryString.getParam('seed');
if (seed) {
env.seed(seed);
config.seed = seed;
}

// Reporters
var htmlReporter = new jasmine.HtmlReporter({
env,
onStopExecutionClick() {
queryString.navigateWithNewParam('failFast',
env.stoppingOnSpecFailure());
},
onThrowExpectationsClick() {
queryString.navigateWithNewParam('throwFailures',
!env.throwingExpectationFailures());
},
onRandomClick() {
queryString.navigateWithNewParam('random', !env.randomTests());
navigateWithNewParam(key, value) {
return queryString.navigateWithNewParam(key, value);
},
addToExistingQueryString(key, value) {
return queryString.fullStringWithNewParam(key, value);
Expand Down Expand Up @@ -136,10 +129,12 @@ function initializePDFJS(callback) {
},
});

env.specFilter = function(spec) {
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};

env.configure(config);

// Sets longer timeout.
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;

Expand Down
33 changes: 14 additions & 19 deletions test/unit/jasmine-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,34 +125,27 @@ function initializePDFJS(callback) {
},
});

var stoppingOnSpecFailure = queryString.getParam('failFast');
env.stopOnSpecFailure(typeof stoppingOnSpecFailure === 'undefined' ?
false : stoppingOnSpecFailure);

var throwingExpectationFailures = queryString.getParam('throwFailures');
env.throwOnExpectationFailure(throwingExpectationFailures);
var config = {
failFast: queryString.getParam('failFast'),
oneFailurePerSpec: queryString.getParam('oneFailurePerSpec'),
hideDisabled: queryString.getParam('hideDisabled'),
};

var random = queryString.getParam('random');
env.randomizeTests(random);
if (random !== undefined && random !== '') {
config.random = random;
}

var seed = queryString.getParam('seed');
if (seed) {
env.seed(seed);
config.seed = seed;
}

// Reporters
var htmlReporter = new jasmine.HtmlReporter({
env,
onStopExecutionClick() {
queryString.navigateWithNewParam('failFast',
env.stoppingOnSpecFailure());
},
onThrowExpectationsClick() {
queryString.navigateWithNewParam('throwFailures',
!env.throwingExpectationFailures());
},
onRandomClick() {
queryString.navigateWithNewParam('random', !env.randomTests());
navigateWithNewParam(key, value) {
return queryString.navigateWithNewParam(key, value);
},
addToExistingQueryString(key, value) {
return queryString.fullStringWithNewParam(key, value);
Expand Down Expand Up @@ -185,10 +178,12 @@ function initializePDFJS(callback) {
},
});

env.specFilter = function(spec) {
config.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};

env.configure(config);

// Sets longer timeout.
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;

Expand Down

0 comments on commit 016c276

Please sign in to comment.