Qunit tests not deterministic in Plugin?

I seem to be running into a race condition in Qunit, in my case running:

rake "plugin:qunit[discourse-multilingual]" with a branch installed.

I’m declaring a function in my initializer (i’m extending I18n)

The tests sometimes (25%?) seem to run before the plugin’s ember initializer has run and fails because the function is not defined.

How do I ensure the plugin’s initializer js has run before the test fires?

test:

definition:

intermittent error:

TypeError: _I18n.default.translate_tag is not a function

OK I resolved this by refactoring. I moved my function out of I18n and into an existing multilingual module.

Something about extending I18n here is not reliable in all scenarios, least of all unit testing, apparently!

1 Like