Uh oh!
There was an error while loading. Please reload this page.
feat(testing): use zones to avoid the need for injectAsync - #5375
Conversation
juliemr
commented
Nov 19, 2015
Zones seem to work smoothly and remove complexity for the user for the async tests. All tests which use |
juliemr
commented
Nov 19, 2015
Note that this isn't actually a breaking change, because both |
0x-r4bbit
commented
Nov 19, 2015
This is awesome Julie! On Thu, Nov 19, 2015, 3:52 AM Julie Ralph notifications@github.com wrote:
|
vicb
commented
Nov 19, 2015
A few minor comments, otherwise LGTM. |
53f6396 to
d3f814cCompareIgorMinar
commented
Nov 19, 2015
@wardbell fyi - this will affect testing docs |
IgorMinar
commented
Nov 19, 2015
looks great! Please deprecate injectAsync and add docs about the async behavior for |
IgorMinar
commented
Nov 19, 2015
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? |
juliemr
commented
Nov 19, 2015
Errors should be properly output: As in this test: it('should fail when an asynchronous error is thrown',(done)=>{varitPromise=patchJasmineIt();it('throws an async error',inject([],()=>{setTimeout(()=>{thrownewError('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();}); |
wardbell
commented
Nov 19, 2015
Big win! Looking forward to trying this. |
d3f814c to
08be30dComparejuliemr
commented
Nov 19, 2015
Deprecation notice and docs are done. |
vsavkin
commented
Nov 25, 2015
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
7d3de24Comparejuliemr
commented
Nov 25, 2015
@vsavkin done! |
IgorMinar
commented
Nov 25, 2015
let's get this in! :) |
vsavkin
commented
Nov 30, 2015
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 resolveangular#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