-
Notifications
You must be signed in to change notification settings - Fork 779
Fix errors on non-browser environments #401
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
Conversation
…ener nor attachEvent.
|
This is actually a fix for the regression caused by f249711 Need to check if not calling QUnit.load at all is actually the desired behavior in non-browser environments. |
|
As a citizen of non-browser world, I'd prefer calling QUnit.load or QUnit.start explicitly after setting proper QUnit.config values and some logging callbacks. This style makes QUnit behaviour on non-browser deterministic. |
|
👍 |
|
Code looks good, but I'll defer merging this until we have a basic test suite for non-browser runs. We should probably use grunt-contrib-qunit or the phantomjs add-on. |
|
Those are both browser-based, though...? You probably want to use something more like node-qunit. |
|
Indeed, we already have phantomjs tests in grunt, which we run on every commit from Jenkins. We've had this for several months now. Don't know what I was thinking.. node-qunit indeed! |
|
I think we need to test QUnit HEAD every time to detect regressions immediately. I'll request another PR about this if possible. |
|
I'd prefer to run the entire test suite instead of just a few basic assertions. It's quite simple:
See also travis-ci-node-qunit for a working example. Actually, |
On non-browser environments, I think calling
When running under browsers (including PhantomJS), |
|
@twada: You need to sign the CLA before we can work on merging this PR. Please add a comment here when you've done so. Thanks! |
|
@JamesMGreene Thanks! I signed. 👌 |
|
The v1.12.0 release breaks with my use because it doesn't export things like |
|
@jdalton we didn't change the exports between 1.11 and 1.12 - your comment sounds like 1.12 has regressions. Did it work for you with 1.11? Or previous versions? |
|
Yes 1.11.0 worked because it was exported as |
|
We shouldn't export those detached as globals, but they should be available through the QUnit object. This distinction is clear in the way we export for the browser, but there's it's not so clear in the export for modules as 1) there's a line missing there, 2) the regular export of the subset don't looks like detached properties when you use them ( extend( window, QUnit.constructor.prototype );
window.QUnit = QUnit; extend( exports, QUnit.constructor.prototype );This should have a: exports.QUnit = QUnit;That way you'll have access to the proper object (to access like |
|
@JamesMGreene can you push your branch into this repo and replace this PR with a new one? Reference this PR and whatever other tickets, add tests for the issue @jdalton brought up. I'm still not sure why we even changed the exports, I didn't see any mention of that in the commit log since 1.11. Too late anyway, so let's get it fixed and prevent future regressions. |
|
For Node.js consumers, when we split the codebase in future releases (per #378), we could just tell them to import such functions via Yes, I'll try to update my branch and submit a new PR today. |
|
Replaced by PR #458. |
|
@moos We would welcome a compliant patch from you that takes care of all the use cases that weren't previously covered. 👍 |
|
I hacked my way through to get QUnit & node.js working for me. This includes @twada's patch above and this bit to address @jdalton's issue that I also ran into: if ( typeof exports !== "undefined" ) { My test file looks like: QUnit.config.reorder = false; QUnit.test('test 1', function(assert){ ... }); QUnit.load(); Also overrode some callbacks (QUnit.log, etc.) per test/node-test.js to get logging. Overall a painful experience :) I love QUnit, but don't think it's ready as a drop-in module in a node.js environment yet. |
Fix errors on non-browser environments since that does not have addEventListener nor attachEvent.
Since QUnit 1.11.0, an error occurs when loading QUnit under non-browser environments. For example, on Node.js,
require('qunitjs')raises an error.Stacktrace on Node.js
This PR is a refinement of closed PR #399