0

I'm writing some tests for an ember project, and I'm looking for a nice way to group certain tests so they can share the same setup/teardown methods.

From what I can tell, it can be done in this way:

moduleFor('adapter:application', 'Unit | Adapter | application', {});
test('Test using first moduleFor, which has no before/after', ...);

moduleFor('adapter:application', 'Unit | Adapter | application', {
  beforeEach() {...},
  afterEach() {...}
});
test('Test using new beforeEach/afterEach', ...);

However I'm thinking that it will be difficult to figure out which before/after applies to tests, without actually nesting the tests within the moduleFor which doesn't appear to be possible with Ember's custom module functions.

Does anybody have any suggestions on how I might implement this more cleanly?

Matt d'
  • 137
  • 1
  • 7
  • make your `beforeEach` and `afterEach` generic enough that every test can use them and aren't negatively affected by them and put one-offs inside the test themselves. – Jason Jan 07 '16 at 21:35

1 Answers1

1

So I'm totally going to be that guy and suggest using ember-cli-mocha since this style testing is done VERY well in it. We use it in all of our projects.

Example of an acceptance test

Example of a integration/unit test

If you need to use qunit I know there's a way to do it, but I've only done it once and I don't think I did it correctly. :/

robdel12
  • 229
  • 2
  • 8