Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test-helper): Fix Sinon/QUnit Assertion Issue #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok that we are importing sinon here? Should this be something passed in? Should it be self.sinon?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to import sinon here, because it's a required dependency through ember-sinon. Even beyond that, though, we shouldn't have to expect people to use this package if they're not using sinon. That's not a workflow we need to support, so import is fine here!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we import QUnit here or is it required to be grabbed from self for some reason?

Copy link
Author

@mwagz mwagz Nov 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just grabbed it from self because you did on line 12. Which also means we could probably swap it to testEnvironment instead. I'm without opinion, which would you prefer?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great point. I think we should definitely swap it to testEnvironment to make sure that still works, and then maybe separate from this change we should consider whether we can just do

import * as QUnit from 'qunit';

I don't trust my past self to have made that decision wisely, but maybe there was a reason for it? XD

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened an issue to separate that question from this PR: #530

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