ember/no-runloop
amk221 opened this issue · comments
Would it be possible to improve the docs around ember/no-runloop
?
- Fresh ember-cli apps use
@ember/runloop
in instance initializer tests. - The readme talks about async cleanup, but there are so many more features in there, like
scheduleOnce('afterRender'...
and,debounce
, etc. - Its necessary to wrap code in
run
in order forember/test-helpers
setupOnerror/resetOnerror
to work.
Fresh ember-cli apps use @ember/runloop in instance initializer tests.
this is probably a bug and the tests should be updated 😅
The readme talks about async cleanup, but there are so many more features in there,
like more alternatives to things you listed?
I imagine it'd be a bit situational -- and in some cases not needed?
but maybe having a few examples would be good -- more examples never hurts.
Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.
It is not
setupOnError
can happen pre-visit, pre-render, and resetOnError
, I usally do after every test so I don't forget about it.
https://github.com/NullVoxPopuli/limber/blob/main/apps/repl/tests/test-helper.ts#L22
Thanks :)
For this one:
Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.
emberjs/ember-test-helpers#1128
In order for setupOnerror
to work, the code that throws needs to be in a run
.
if you don't want code in a run
, you could use window.addEventListener('error'
? perhaps?
using run
at all is some api leakage 😅
setupOnerror
doesn't work with window.addEventListener
though? Anyway, that's off topic. My point is, there are reasons to use the @ember/runloop
(and therefore ignore the eslint warning). At this moment in time.