Skip to content

feat(testing): add Done provider for tests that need more async control - #8159

Closed
juliemr wants to merge 1 commit into
angular:masterfrom
juliemr:done
Closed

juliemr wants to merge 1 commit into
angular:masterfrom
juliemr:done

Conversation

@juliemr

@juliemr juliemr commented Apr 20, 2016

Copy link
Copy Markdown
Contributor

If the async test zone (e.g. async(inject(...))) won't work for
your tests, add the option to defer to the Jasmine done function
within inject.

Usage:

it('does stuff', inject([Service, Done], (service, done) {
  service.doStuff().whenFinished(done);
}));

Closes #8156

@juliemr juliemr added area: testing Issues related to Angular testing features, such as TestBed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 20, 2016
@juliemr

juliemr commented Apr 20, 2016

Copy link
Copy Markdown
Contributor Author

cc @wardbell @jeffbcross

@jeffbcross

Copy link
Copy Markdown
Contributor

LGTM!

2 Travis jobs are failing on:

../../../../../tmp/test.typings/1461183968319/testing/ts/testing.ts(95,58): error TS7006: Parameter 'service' implicitly has an 'any'

And another job looks like a pub flake.

@jeffbcross jeffbcross added pr_state: LGTM action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 21, 2016
@jeffbcross jeffbcross assigned juliemr and unassigned vikerman Apr 21, 2016
@0x-r4bbit

Copy link
Copy Markdown
Contributor

@juliemr can you shed some light on this? When exactly is this needed? I thought the new async() function takes care of this?

@juliemr

juliemr commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

@PascalPrecht This is for rare situations where you can't use async. Most users should never need it.

An example would be if you have a setTimeout and you really want to test something that happens on the third iteration.

@juliemr
juliemr force-pushed the done branch 2 times, most recently from 6511f77 to 4c7b763 Compare April 21, 2016 17:52
If the async test zone (e.g. `async(inject(...))`) won't work for
your tests, add the option to defer to the Jasmine done function
within inject.

Usage:

```js
it('does stuff', inject([Service, Done], (service, done) {
  service.doStuff().whenFinished(done);
}));
```
@juliemr juliemr added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 21, 2016
@juliemr

juliemr commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

Travis is happy now - adding to merge queue.

@juliemr juliemr added state: blocked and removed action: merge The PR is ready for merge by the caretaker labels Apr 21, 2016
@juliemr

juliemr commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

Putting this on hold while @vikerman investigates a different method.

@juliemr

juliemr commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

FYI - the method we're investigating would look something like:

it('does foo', (done) => {
  inject([Service}, (service) => {
    doStuff();
    // sometime later asynchronously
    done();
  });
});

@juliemr

juliemr commented Apr 26, 2016

Copy link
Copy Markdown
Contributor Author

Will instead allow use of done and inject with #8257

See particularly example like #8257 (comment)

@juliemr juliemr closed this Apr 26, 2016
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: testing Issues related to Angular testing features, such as TestBed cla: yes state: blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a user-friendly way to get at Jasmine's done fn

5 participants