-
Notifications
You must be signed in to change notification settings - Fork 378
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
Qunit2 support? #155
Comments
Let alone QUnit2, I think it also does not work with qunit 1.23.1, I tried to upgrade to that version, I got this error in this function, "Uncaught Error: Called stop() outside of a test context" /[email protected]#browser/adapters/qunit/ |
Timeline is when it's done. Please send a PR if you have it working. Not sure about your other problem with 1.23.1, can you provide a breaking example? |
hi there, so it turns out that as of QUnit 1.17, the error occurs only if I use F.open() inside the QUnit.moduleStart() callback I attached a set of examples to demonstrate this this was the reason some of our tests were failing Question is: are we doing something out of model or is FuncUnit? Resolving this will help us move to 1.23.1 I think which will be great as we prepare to do 2.0 To run, open attached zip and run testpage-1.14.html. It works |
Thanks for the example! |
hello there, please let me know if I can help in any way here. I am prepping to submit the sendKeys in another pull request so I am sort of setup to run the tests locally and all that, so if you have any ideas I can try, I am do that. Apparently the use of QUnit.start/stop are the problems, but I am not sure what to replace it with since there are no globals anymore! |
No globals is ok, you pass QUnit to FuncUnit using Here's the code that detects if the thing you pass into .attach is QUnit: https://github.com/bitovi/funcunit/blob/master/browser/adapters/adapters.js#L84-L86 I don't know what has changed with QUnit2 to tell you if/how that needs to change. But it needs to correctly detect that the QUnit object is the QUnit object, if that makes sense. From there you need to update the qunit adapter (or create a new one specially for qunit2): https://github.com/bitovi/funcunit/blob/master/browser/adapters/qunit.js Without knowing all what has changed I can't guide too much here unfortunately. One problem could be if QUnit2 no longer has stuff like |
ok so I find that if I replace
with the following, I get rid of this problem,
According to the qunit 2 upgrade guide, QUnit.moduleStart is still supported if called directly as a function So whatever way QUnit is checking that QUnit.start and stop are being called outside of test content, that check fails in the first scenario but passes in the second. Interesting. However, if I use the above, the test fails in a different way where click is not working. |
ok with Qunit 1.23.1 I have fully verified that the use of F.open/wait etc in QUnit.moduleStart/moduleDone fails like above but the same functions when used in the beforeEach and afterEach callbacks of QUnit do work
Next step for me is to repeat with QUnit 2.x and see what happens. This may be an acceptable workaround but it will require us to change thousands of files perhaps in our test bed, so a bit annoying in the least |
Unfortunately the solution may not be that simple after all from my limited knowledge of this. Unless QUnit somehow allows this type of usage. Here is what I have concluded thus far
More specifically, if I try to use assert.async in FuncUnit's QUnit adapter like this,
I get this error
So I am not sure that the next logical step is here. Whether it is to have QUnit somehow allow this type of usage, or for us to stop using F.open/close in moduleStart/stop. The latter can be done if there is no other way. |
I have made following changes in these files make this work with QUnit 2
FuncUnit = function( selector, frame ) {
// if you pass true as context, this will avoid doing a synchronous query
var frame,
forceSync,
isSyncOnly = false;
var callerFirstArgument = FuncUnit.caller.arguments[0];
if(callerFirstArgument && callerFirstArgument.test){
FuncUnit.assert = callerFirstArgument;
} 2- Use local assert in place of global assert if(window.QUnit) {
var done,
assert;
FuncUnit.unit = {
pauseTest:function(){
assert = FuncUnit.assert;
done = assert.async();
},
resumeTest: function(){
done();
},
assertOK: function(assertion, message){
assert.ok(assertion, message);
},
equiv: function(expected, actual){
return QUnit.equiv(expected, actual);
}
} |
Thanks @shayaneumar, do you plan to submit these? Does this allow fully updating to a new QUnit version 1.14 or higher? |
@binodpanta I have tested it only with qunit v2.3.2, changes suggested here are also not backward compatible. I am not very confident with the code change above I was thinking anyone from the team can help me with this, I want o upgrade my tests to qunit2 asap. I will try to raise a PR for this if I get some time. |
If it isn't backward compatible, we can always release it as a major-version update. |
I've not really been following this. Is it possible to test which version of QUnit is present and do the right thing? |
@binodpanta here is the PR to support that stealjs/steal-qunit#26. |
This update does not seem to resolve the initial issue raised by @binodpanta where calling F.open() from a callback passed to QUnit.moduleStart() throws. In 1.23.1 the |
indeed this will be a major blocker for us |
Just want to raise this point (I have asked Kevin to discuss this with the core group at some point) I just wanted to make this point that this problem is demonstrable if you take FuncUnit out of the picture and do this ( feel free to use this content when you discuss with the FuncUnit team, if needed )
So the analysis here is:
Question now is , which of these is approaches is the best fix?
Puzzle for me is : |
hey @binodpanta, Manuel here, I work at Bitovi and I'd like to help solve this issue. I'm kinda confused about what's exactly the problem here.
That said, if you use QUnit.module( "module A", {
before: function() {
// prepare something once for all tests
},
beforeEach: function() {
// prepare something before each test
},
afterEach: function() {
// clean up after each test
},
after: function() {
// clean up once after all tests are done
}
}); if you have a breaking example that would be useful, too. I looked into the zip file you shared and rewriting your test to: F.attach(QUnit);
QUnit.module("testing qunit 1.17", {
before: function() {
F.open("./anotherpage.html");
};
});
QUnit.test("atest", function(assert) {
F("body").visible("assertion needed");
F.wait(1, function(){F.win.close();});
}); made it pass! |
if you are concerned about changing a bunch of tests, you could look into a codemod to make it easier. We recently migrated all stealjs tests to Qunit 2.x stealjs/steal#1154 and with |
Looks like there is no version of Funcunit yet that support QUnit2? Is there a plan to release FuncUnit for qunit2, if so, what is the timeline on it?
The text was updated successfully, but these errors were encountered: