feat(testing): use zones to avoid the need for injectAsync#5375
feat(testing): use zones to avoid the need for injectAsync#5375juliemr wants to merge 1 commit intoangular:masterfrom
Conversation
|
cc @vicb @IgorMinar Zones seem to work smoothly and remove complexity for the user for the async tests. All tests which use |
|
Note that this isn't actually a breaking change, because both |
|
This is awesome Julie! On Thu, Nov 19, 2015, 3:52 AM Julie Ralph notifications@github.com wrote:
|
|
A few minor comments, otherwise LGTM. |
53f6396 to
d3f814c
Compare
|
@wardbell fyi - this will affect testing docs |
|
looks great! Please deprecate injectAsync and add docs about the async behavior for |
|
OMG, I just realized that this might mean that we don't need to refactor all of our tests in Do we properly detect errors and surface them or will we still see jasmine timeouts when an error occurs in an async test? |
|
Errors should be properly output: As in this test: it('should fail when an asynchronous error is thrown', (done) => {
var itPromise = patchJasmineIt();
it('throws an async error',
inject([], () => { setTimeout(() => { throw new Error('bar'); }, 0); }));
itPromise.then(() => { done.fail('Expected function to throw, but it did not'); }, (err) => {
expect(err.message).toEqual('bar'); // <-- bar not just timeout!
done();
});
restoreJasmineIt();
}); |
|
Big win! Looking forward to trying this. |
d3f814c to
08be30d
Compare
|
Deprecation notice and docs are done. |
|
Could you rebase? |
Use a zone counting timeouts and microtasks to determine when a test is finished, instead of requiring the test writer to use injectAsync and return a promise. See angular#5322
c49380d to
7d3de24
Compare
|
@vsavkin done! |
|
let's get this in! :) |
|
Merged via 0c9596a |
Before angular#5375, injectAsync would check the return value and fail if it was not a promise, to help users remember that they need to return a promise from an async test. angular#5375 removed that with the introduction of the testing zone. This un-deprecates `injectAsync` until we can resolve angular#5515. To be clear, this means that `inject` and `injectAsync` are now identical except that `injectAsync` will fail if the test does not return a promise, and `inject` will fail if the test returns any value.
Before #5375, injectAsync would check the return value and fail if it was not a promise, to help users remember that they need to return a promise from an async test. #5375 removed that with the introduction of the testing zone. This un-deprecates `injectAsync` until we can resolve #5515. To be clear, this means that `inject` and `injectAsync` are now identical except that `injectAsync` will fail if the test does not return a promise, and `inject` will fail if the test returns any value. Closes #5721
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Use a zone counting timeouts and microtasks to determine when a test
is finished, instead of requiring the test writer to use
injectAsync and return a promise.
See #5322