-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Implement RFC 232 (New QUnit Testing API) #208
Comments
I think it would make sense to import it from ember-qunit, since you are already importing the test function from there anyway. Agree with forbidding nested moduleFor. Would calls to |
|
Ya, seems a bit like a troll the way I initially proposed it. |
@rwjblue, is the problem on exposing module due to the name? If the nested modules are really necessary for ember-qunit they could be exposed with a different name, like
That's a very reasonable PoV. Keep in mind the advantage (maybe the only) on nested modules is sharing module hooks and |
anyway, ping me if you want any help from QUnit or even to give a feedback. |
@leobalter We have the same few test cases we have in every component integration test that we consistently name across all of our components. These test case are in addition to other ones that are specific to each respective component. I anticipate using nested models as a way to group these "default" test cases. Admittedly, I have not done enough research yet to ascertain the viability of this. |
No, mostly that the example in the issue description had some things imported from
Ya, exactly. The kind of sharing and grouping that folks could do with: moduleForComponent('asdfasd', function() {
module('hjkl', function() {
test('some thing', function(assert) { });
});
}); Is perfect, but to have: moduleForComponent('asdf', function() {
moduleForComponent('hjkl', function() {
test('some thing', function(assert) { });
});
}); Would be pretty confusing since it is completely non-obvious what the behavior should actually be. ember-qunit has a whole slew of default setup steps that happen normally for
Thanks @leobalter! Will keep you updated as we progress... |
Completely agreed, grouping (for shared |
@rwjblue What I meant with my question about moduleForComponent('mycomp', function() {
module('when state is x', function(hooks) {
hooks.beforeEach(function() {
this.set('myFn', myStubFnA);
};
test('should do j', function(assert) {
...
};
test('should do k', function(assert) {
...
}
};
module('when y', function(hooks) {
test('should do l', function(assert) {
...
};
};
} |
also is it possible not to have to deal with the |
@toddjordan - Each In your example:
Not really (as far as I know, but @leobalter might have additional insight). For ember-qunit itself, I'd like to stay as close to QUnit's nested module implementation as possible and not invent our own syntax any more than we have too...
You are basically describing |
Thanks, makes sense. one more question... would tests at the moduleFor level be defined within the moduleFor function? Currently the are defined outside, but it might make more sense like below with nested modules: moduleForComponent('x', function() {
test('should do x', function(assert) {
};
module('when doing something', function() {
...
};
}; |
Yes. See my example in the issue description, it looks roughly like what you have here. |
👍 from me, I'm looking forward to the new capability 😎 |
The hooks object on modules are optional, you may use them as the second argument on a module call or from the first parameter of the callback function. // hooks as arguments, they look messy with the nested function:
module('my module',
{
beforeEach: function(assert) {
assert.ok(true);
}
},
function() {
test('foo', ...);
}
); // hooks from the callback parameter, they are functions here
module('my module', function(hooks) {
hooks.beforeEach(function(assert) {
assert.ok(true);
});
test('foo', ...);
);
// if you have a ES2015 ready environment:
module('my module', function({beforeEach}) {
beforeEach(function(assert) {
assert.ok(true);
});
test('foo', ...);
);
// If you really like describe and it methods:
// if you have a ES2015 ready environment:
var {
describe: module,
it: test
} = QUnit;
describe('my module', function({beforeEach}) {
beforeEach(function(assert) {
assert.ok(true);
});
it('foo', ...);
); You can write your modules without using any hook: module('my module', function() {
test('foo', ...);
}); |
I am happy to see that this functionality, which is already provided by QUnit, will be shipped to Ember-QUnit. I am struggling with test names ever since I moved to Ember, it feels weird to do BDD without nested modules, and it also feels weird to do unit testing for a product. I guess that you guys, when making the framework, don't quite feel the need for testing behaviour, but I certainly feel it when making a web application. |
Only chiming into mostly echo since you asked: I think your current front runner is what most people would expect. I totally see why nested
And declaring a new The only bikeshedding I have to offer is that the name |
@trentmwillis - We should circle back around on this one... |
|
If you mean
Yes, this is default QUnit behavior and must continue to work (for backwards compat).
Both versions are supported and documented under QUnit.module, and I think we would want to support both here also. |
Sounds good. What I meant with the submodule question was whether to reexport |
I'm onboard with this. I'd like to start pushing us in a direction where we nest modules more anyway as it allows for better organization/filtering. I think the implementation will be fairly straightforward so long as we don't allow
I think we should avoid renaming/aliasing functions, but we can make our examples more explicit by giving examples like: import { moduleFor, module as subModule } from 'ember-qunit'; |
I see this is on hold for more than 1 year. Is there a workaround that allows to nest Qunit modules? |
Yes, work is underway to implement emberjs/rfcs#232 which removes all of our custom wrapping around QUnit (and therefore allows us to fully embrace QUnit’s functionality here). |
Closed by #286. |
I would like to support nested modules, but I am unsure of the exact API.
Current front runner:
Random thoughts:
module
fromqunit
andmoduleFor
fromember-qunit
. I suppose I could exposemodule
fromember-qunit
, but this is something that we have avoided so far....moduleFor
invocations. If you are testing two different modules, IMHO, you should be using different test files. I am uncertain how you could stack twomoduleFor
calls anyways (because both of their setups would try to "own" the test context and whatnot). Need to determine how to detect that we are being called in a nested context...The text was updated successfully, but these errors were encountered: