I have written some ember acceptance test cases. The thing is when I visit the URL http://localhost:4200/tests and filter module by Acceptance, the test cases are running lightning fast. Even though those were written in async await function.
I want to put a time delay for each line using ember run loop run.later or run.next. But that's not the solution.
Is there a way to add slow mode somewhere in the top of the application (or) Is there any test helpers which is already present? So I can see test cases running in action.
There's no "slow mode" for Ember testing, but you can use regular JavaScript methods to slow down your tests yourself. For example, below we've created a
waitmethod that you can call in between each step of the test.This question was featured on an episode of May I Ask a Question! You can watch the recording to see examples of how to use the code below plus how to use the debugger and
pauseTest.This code will wait one second before moving to the next line, anywhere you put
await wait():I also recommend using your browser's debugger to step through code at your own pace. It's really powerful and will probably help you more than slowing down tests, in most cases.
this.pauseTest()is also very helpful.There's also the possibility of using a JavaScript generator for some less-cluttered code, but if you use this, your tests won't exit properly, so it's a temporary approach: