I use jasmine runs and wait to test asynchronous operations. Everything works fine but I\'m not quite sure what goes on behind the scenes.
The jasmine documentation
waitsFor
does block until the conditions it's waiting for are met or it times out.
From the jasmine docs: "waitsFor() provides a better interface for pausing your spec until some other work has completed. Jasmine will wait until the provided function returns true before continuing with the next block.".
The linked docs also have a slightly clearer example or waitsFor
.
EDIT: Ah I see what you mean now. waitsFor
won't block JS that isn't wrapped in runs
, waitsFor
, ect.
What jasmine is doing is taking the function passed to it via runs
or waitsFor
and if jasmine is not currently waiting, it executes the function immediately. If it is waiting, it doesn't call it until it's finished waiting.
That doesn't stop the console.log
as it's been passed to jasmine so jasmine can't prevent it from being executed straight away.