Skip to content

Commit

Permalink
fix(test-helper): Fix Sinon/QUnit Assertion Issue
Browse files Browse the repository at this point in the history
This change wraps the pass/fail from sinon.assert in a Qunit.ok assertion. This makes it
so that Qunit detects sinon.assert as an actual assertion.

sinon.assert methods are not detected as QUnit Assertions. When no qunit assertions exist
in the test, Qunit will throw an error:

"Expected at least one assertion, but none were run - call expect(0) to accept zero assertions."

This is expected behavior from Qunit, but when we assert with sinon.assert, there is technically
assertion there.
  • Loading branch information
mwagz committed Nov 11, 2021
1 parent bffac23 commit 6e406c0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addon-test-support/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sinon from 'sinon';
import { createSandbox, restoreSandbox } from './sinon-sandbox';

/**
Expand All @@ -11,4 +12,7 @@ import { createSandbox, restoreSandbox } from './sinon-sandbox';
export default function setupSinon(testEnvironment = self.QUnit) {
testEnvironment.testStart(createSandbox);
testEnvironment.testDone(restoreSandbox);

sinon.assert.pass = (assertion) => self.QUnit.assert.ok(true, assertion);
sinon.assert.fail = (assertion) => self.QUnit.assert.ok(false, assertion);
}

0 comments on commit 6e406c0

Please sign in to comment.