10

I have to exec some code before all tests began. So I need to use QUnit hook before but in ember-qunit the only callbacks available are beforeEach and afterEach.

How can I perform that?

ykaragol
  • 6,139
  • 3
  • 29
  • 56
EnriMR
  • 3,924
  • 5
  • 39
  • 59
  • If i'm not wrong, no other callbacks are available. [code](https://github.com/emberjs/ember-qunit/blob/master/lib/ember-qunit/qunit-module.js#L38). What do you want to do in `before` callback? – ykaragol Oct 11 '16 at 11:12
  • I need to init a dependency injection manager class that shouldn't be called twice – EnriMR Oct 12 '16 at 11:28
  • 1
    Can you do it just before the `module` function call? Such as shown in [here](https://ember-twiddle.com/860f6eea3beb86c65490ea2f29e9c36b?openFiles=tests.unit.controllers.my-controller-test.js%2C) – ykaragol Oct 13 '16 at 07:13
  • Here take a look at this https://github.com/flore77/qunit/commit/15775d2a1873247bd19863cf41e386e26164c881 code and this https://github.com/jquery/qunit/issues/893 issue.Hope it might help a bit – Pritish Vaidya Oct 15 '16 at 00:08

1 Answers1

1

When I wrote my first comment on this quesion, the repository were like this: qunit-module.js. So it seems there were no support for before and after hooks. So my suggestion was initiating the manager before module function, shown as in this twiddle.

But, 5 days ago, trentmwillis submitted a commit and it seem master now a has the before and after hooks. I guess ember-qunit's 2.1.2 version has this commit.

Community
  • 1
  • 1
ykaragol
  • 6,139
  • 3
  • 29
  • 56