feat(test): allow tests to specify the platform and application providers used#5975
feat(test): allow tests to specify the platform and application providers used#5975juliemr wants to merge 1 commit intoangular:masterfrom
Conversation
|
Still to do:
|
822918a to
8fba327
Compare
|
This is now squashed and has a real commit message noting the breaking change. Waiting for Travis, but all the unit test suites are passing locally. Ready for review! |
ad916ed to
0891f79
Compare
0891f79 to
6e48522
Compare
|
Note that this will require a change in g3 to remove a use of |
|
I'm a bit confused because I'm not sure what "platform providers" are. I know what PLATFORM_DIRECTIVES are. I know what PLATFORM_PIPES are. We need to account for both of these during our testing ... both to load them by default perhaps AND to facilitate mocking them under test. We have a mechanism for setting up providers and for overloading the (implicit) providers that A2 registers by default. |
|
The |
6e48522 to
d26204c
Compare
|
The terminology challenge for me is that provider != directive != pipe. I must have missed something along the way. I hadn't realized that directives, components, and pipe are all "provided" ... like anything else I toss in the injector. I thought they went somewhere special with their own namespace. This also means that, withing the same injector, I can replace any directive by writing I can do that in my production code, not just in tests. Does that sound right? I haven't tried it. |
|
Is it save to assume that you reset the "standard directives set" if I mock one of them out during a test? Suppose I spy on the |
|
Yes, everything is reset between tests. |
|
For the record, based on our conversation, I had the wrong mental model. Here is my revised understanding ... which we hope conforms to reality. Providers, Directives, and Pipes are their own categories. There are good reasons why we have separate The "provider" with the token "PLATFORM_DIRECTIVES" is an array of directives that Angular stashes in the top injector. When Angular gets ready to look for directives in a template, it combines what we list in our The test apparatus described in this PR is a way to configure the platform common providers and platform directives for the test suite. |
|
Dear merge-master: This will require a small change to g3. Here's a doc with all the info: https://docs.google.com/document/d/10N5YrdavEECZt-WJhYw7967RFrzF7tmLiihHXAhKxc8 After a talk with users teams, it sounds like we should wait until after the holidays to make any sort of changes, so consider this ready but waiting. |
|
the doc says "We should wait until after the holiday freeze to be sure the On Mon, Dec 21, 2015 at 3:05 PM Julie Ralph notifications@github.com
|
|
Yes! Sorry, my comment was edited to say that but edits don't get out to emails. I did not start the rumor :) |
f40ceaa to
17e6a5e
Compare
|
FYI - this is now rebased on top of the recent freezing code changes. |
|
Test failures are due to new saucelabs_required test target. @mgol do you happen to have time to take a look and see if these are legitimate? I'm surprised by all the zone failures. |
33de8d6 to
ee6d1b9
Compare
|
The failures on FireFox and IE were due to a global setup on load in testing utils |
ee6d1b9 to
1357bee
Compare
…ders used
With providers split into bundles, the test injector is now able to
use providers for a given bundle. Suggested provider lists for tests are
available in `angular2/platform/testing/<platform>`.
Change the providers for a test suite using `setBaseTestProviders`. This
should be done once at the start of the test suite, before any test cases
run.
BREAKING CHANGE: Tests are now required to use `setBaseTestProviders`
to set up. Assuming your tests are run on a browser, setup would change
as follows.
Before:
```js
// Somewhere in test setup
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
BrowserDomAdapter.makeCurrent
```
After:
```js
// Somewhere in the test setup
import {setBaseTestProviders} from 'angular2/testing';
import {
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS
} from 'angular2/platform/testing/browser';
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS);
```
Closes angular#5351, Closes angular#5585
1357bee to
60943fe
Compare
|
Merging PR #5975 on behalf of @rkirov to branch presubmit-rkirov-pr-5975. |
|
Did this made it to beta.2? Because I cannot find neither of |
|
@rolandjitsu see #6771 |
|
@pkozlowski-opensource thanks. |
|
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. |
With providers split into bundles, the test injector is now able to
use providers for a given bundle. Suggested provider lists for tests are
available in
angular2/platform/testing/<platform>.Change the providers for a test suite using
setBaseTestProviders. Thisshould be done once at the start of the test suite, before any test cases
run.
BREAKING CHANGE: Tests are now required to use
setBaseTestProvidersto set up. Assuming your tests are run on a browser, setup would change
as follows.
Before:
After:
Closes #5351, Closes #5585