Skip to content

chore(testing): Refactor test methods to have a uniform interface. - #8257

Closed
vikerman wants to merge 1 commit into
angular:masterfrom
vikerman:test_refactor
Closed

vikerman wants to merge 1 commit into
angular:masterfrom
vikerman:test_refactor

Conversation

@vikerman

Copy link
Copy Markdown
Contributor

Remove FunctionWithParamTokens.

All test wrappers async, fakeAsync and inject now return just a Function instead of FunctionWithParamTokens. This makes them directly consumable by the test framework. Also the test framework code does not have to handle a union of Function and FunctionWithParamTokens everywhere.

The Function returned by the above are considered asynchronous by the test framework if they return a Promise, synchronous otherwise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return inject... here?

@vikerman vikerman Apr 26, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Good catch. And add a test for withprovider and AsyncTestCompleter which is where this would have mattered

@juliemr

juliemr commented Apr 26, 2016 •

Copy link
Copy Markdown
Contributor

A couple small comments but overall this looks great, much cleaner!

Can we add an example to https://github.com/angular/angular/blob/master/modules/angular2/test/testing/testing_public_spec.ts showing the use of done and inject? Something like

it('should allow inject and done', (done) => {
  inject([FancyService] (service) => {
    let count = 0;
    setInterval(() => {
      count++;
      if (count > 2) { done(); }
    }, 5);
  })();
});

@juliemr juliemr added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 26, 2016
@juliemr juliemr assigned vikerman and unassigned juliemr Apr 26, 2016
@vikerman

Copy link
Copy Markdown
Contributor Author

Test timing after all "it" methods are wrapped with (done)=> {}

JS(No change):
master: SUCCESS (27.341 secs / 23.577 secs)
PR: SUCCESS (26.694 secs / 23.059 secs)

CJS (Maybe little slower after change)
master: Finished in 12.52 seconds
PR: Finished in 13.01 seconds

Remove FunctionWithParamTokens.

All test wrappers async, fakeAsync and inject now return just a Function instead of FunctionWithParamTokens. This makes them directly consumable by the test framework. Also the test framework code does not have to handle a union of Function and FunctionWithParamTokens everywhere.

The Function returned by the above methods are considered asynchronous by the test framework if they return a Promise, synchronous otherwise.
@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 26, 2016
@mary-poppins

Copy link
Copy Markdown

Merging PR #8257 on behalf of @hansl to branch presubmit-hansl-pr-8257.

@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

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants