while testing Promise, async functions, and async generators, sometimes I want to use timer in test script (not for automated test tho). would it be possible to add setTimeout or similar thing to JS shell so that we can test such cases in shell? main concern is that JS shell version of setTimeout might behave differently than DOM setTimeout...
Presumably what you are looking for is a function that does "run this code when there are no promises pending"? This doesn't seem too hard to implement in the abstract, mostly the shell main program becomes a loop with a deadline-sorted list of callbacks instead of the straight-line code it already is. (BTW, it is my understanding that both V8 and Chakra have more DOM-like interfaces in their JS shells - Worker objects, postMessage channels. It's possible we should think about moving in that direction too, to allow simpler testing.)
yeah, indeed, it's not required to wait long time, but just execute the function (or just resolve the Promise) in specified order, after performing all pending jobs. I'll look into that direction, and also V8/Chakra shells' implementation.
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.