Skip to content

Commit

Permalink
Update "noglobals" from QUnit.log to QUnit.on('testEnd') event
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Jun 11, 2024
1 parent a7ff5a3 commit 4d40eee
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/qunit_noglobals.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
var failures = [];
QUnit.log(function(details) {
if (details.result === false) {
failures.push(details.message);
QUnit.config.reorder = false;

var failures;
QUnit.on('testEnd', function(test) {
if (!failures) {
failures = test.errors;
}
});

QUnit.todo('global pollution', function(assert) {
window.pollute = true;
assert.ok(pollute, 'nasty pollution');
window.myPollution = true;
assert.true(myPollution, 'nasty pollution');
// We expect QUnit to add an error to the end of this test
});

QUnit.test('actually check for global pollution', function(assert) {
QUnit.test('check result of previous test', function(assert) {
assert.expect(1);
assert.deepEqual(failures, ['Introduced global variable(s): pollute']);
assert.propContains(failures, [
{ message: 'Introduced global variable(s): myPollution' }
]);
});

0 comments on commit 4d40eee

Please sign in to comment.