151 Commits

Author SHA1 Message Date
Alex Rickabaugh
94893accdb fix(ivy): fix invalid provider error messages under TestBed ()
An @NgModule with invalid provider declarations produces errors under
normal circumstances. However, within the TestBed two small issues with
provider overrides interfered with the correct production of these errors:

1. a 'null' provider object caused a premature crash when the TestBed
   attempted to check for a 'provide' property on it with hasOwnProperty().
2. the array of providers would have an empty override array appended to it
   for each input provider, which would pollute the error messages produced
   down the line.

This commit fixes both of these issues, by 1) checking for null and 2)
filtering out the empty override arrays.

Testing strategy: future commits change the way the TestBed compiles
modules, causing tests to become sensitive to this bug if not fixed.

PR Close 
2019-01-11 11:18:10 -08:00
Misko Hevery
885f1af509 build: extract interface and util sub compilation from core ()
PR Close 
2019-01-10 16:31:44 -08:00
Andrew Kushnir
4694c93315 refactor(ivy): avoid transitiveScopesFor function duplication in TestBed ()
TestBed used to have its own implementation of the `transitiveScopesFor` function, customized for TestBed needs (to compile NgModules). This change unifies the `transitiveScopesFor` function usage by importing it from the `jit/module.ts` script and adding extra argument to configure its behavior (how to compile NgModule), so that TestBed can leverage it.

PR Close 
2019-01-09 17:13:11 -08:00
Andrew Kushnir
a75c734471 fix(ivy): restore NG defs after running tests in TestBed ()
`R3TestBed` allows consumers to configure a "testing module", declare components, override various metadata, etc. To do this, it implements its own JIT compilation, where components/directives/modules have Ivy definition fields generated based on testing metadata. It results in tests interfering with each other. One test might override something in a component that another test tries to use normally, causing failures.

In order to resolve this problem, we store current components/directives/modules defs before applying overrides and re-compiling. Once the test is complete, we restore initial defs, so the next tests interact with "clean" components.

PR Close 
2019-01-07 14:44:14 -08:00
Alan Agius
b61dafaeac refactor: remove redundant error in catch ()
PR Close 
2019-01-04 15:42:19 -08:00
Andrew Kushnir
38b4d15227 fix(ivy): implement 'TestBed.overrideTemplateUsingTestingModule' function ()
Adding 'TestBed.overrideTemplateUsingTestingModule' function that overrides Component template and uses TestingModule as a scope.

PR Close 
2019-01-04 12:19:20 -08:00
Andrew Kushnir
a9790018df fix(ivy): resolve forwardRefs correctly in TestBed (JIT) ()
Forward refs in some places (like imports/export/providers/viewProviders/queries) were not resolved before passing to compilation phase. Now we resolve missing refs before invoking compile function.

PR Close 
2019-01-03 09:34:15 -08:00
Andrew Kushnir
4b67b0af3e fix(ivy): adding TestBed.overrideProvider support ()
Prior to this change, provider overrides defined via TestBed.overrideProvider were not applied to Components/Directives. Now providers are taken into account while compiling Components/Directives (metadata is updated accordingly before being passed to compilation).

PR Close 
2018-12-21 16:39:34 -05:00
Andrew Kushnir
509aa61619 fix(ivy): apply all overrides from TestBed, not the last one only ()
In some cases in our tests we can define multiple overrides for a given class. As a result, only the last override is actually applied due to the fact that we store overrides in a Type<->Override map. This update changes the logic to keep all overrides defined in a given test for a Type (i.e. Type<->Override[] map) and applies them one by one at resolution phase. This behavior is more inline with the previous TestBed.

PR Close 
2018-12-21 15:09:00 -05:00
Miško Hevery
e94975d109 fix(ivy): check semantics of NgModule for consistency ()
`NgModule` requires that `Component`s/`Directive`s/`Pipe`s are listed in
declarations, and that each `Component`s/`Directive`s/`Pipe` is declared
in exactly one `NgModule`. This change adds runtime checks to ensure
that these sementics are true at runtime.

There will need to be seperate set of checks for the AoT path of the
codebase to verify that same set of semantics hold. Due to current
design there does not seem to be an easy way to share the two checks
because JIT deal with references where as AoT deals with AST nodes.

PR Close 
2018-12-17 14:49:51 -08:00
Pawel Kozlowski
913563a41d test(ivy): finish root cause analysis for @angular/core TestBed failing tests ()
PR Close 
2018-12-06 13:41:02 -08:00
Kristiyan Kostadinov
7ec05b4d8c fix(ivy): run initialializers in TestBed on init ()
Fixes the initializers not being run by `TestBed` when creating a fixture.

PR Close 
2018-12-03 14:37:49 -08:00
Misko Hevery
39e426cde3 fix(ivy): TestBed.get(Compiler) throws "Error: Runtime compiler is not loaded" ()
BREAKING CHANGE:

The public API for `DebugNode` was accidentally too broad. This change removes
1. Public constructor. Since `DebugNode` is a way for Angular to communicate information
   on to the developer there is no reason why the developer should ever need to
   Instantiate the `DebugNode`
2. We are also removing `removeChild`, `addChild`, `insertBefore`, and `insertChildAfter`.
   All of these methods are used by Angular to constructor the correct `DebugNode` tree.
   There is no reason why the developer should ever be constructing a `DebugNode` tree
   And these methods should have never been made public.
3. All properties have been change to `readonly` since `DebugNode` is used by Angular
   to communicate to developer and there is no reason why these APIs should be writable.

While technically breaking change we don’t expect anyone to be effected by this change.

PR Close 
2018-11-27 13:42:23 -08:00
Miško Hevery
60e403bf6d build: ts-api-guardian should support interface with value types ()
This fixes an issue where a value would hide the type.

```
export interface Foo {
  someMethod(): void;
}

export const Foo: Function = ...;
```

In the above example the `Foo` constant will hide the `interface Foo` symbol.
This change properly saves the interface in addition to the type.

PR Close 
2018-11-27 13:42:23 -08:00
Kristiyan Kostadinov
5247594e86 fix(ivy): add support for providers in TestBed.configureCompiler ()
Adds support for the `providers` that are passed in through `TestBed.configureCompiler` and scopes the error only if the consumer has passed in `useJit`.

PR Close 
2018-11-12 15:33:56 -08:00
Kristiyan Kostadinov
e5c9f7a507 fix(ivy): provide NgZone to ComponentRef ()
Fixes the r3 `TestBed` not providing an `NgZone` to the `ComponentFixture`.

PR Close 
2018-11-12 12:47:07 -08:00
Kara Erickson
78b6f88cb3 fix(ivy): TestBed should use an NgZone ()
PR Close 
2018-11-09 09:56:36 -08:00
Greg Magolan
1f3331f5e6 build(bazel): use fine-grained npm deps () ()
PR Close 
2018-10-19 20:59:29 -07:00
Pete Bacon Darwin
3903e5ebe7 docs: update core to use @publicApi tags ()
PR Close 
2018-10-19 14:35:53 -07:00
Pete Bacon Darwin
24521f549c docs: convert all @experimental tags to @publicApi tags ()
PR Close 
2018-10-19 14:35:52 -07:00
Pawel Kozlowski
f8195e5e3d fix(ivy): stub TestBed.compileComponents implementation ()
PR Close 
2018-10-17 13:08:14 -07:00
Alex Rickabaugh
79466baef8 fix(ivy): remove metadata from *Def and introduce *DefWithMeta types ()
Previously in Ivy, metadata for directives/components/modules/etc was
carried in .d.ts files inside type information encoded on the
DirectiveDef, ComponentDef, NgModuleDef, etc types of Ivy definition
fields. This works well, but has the side effect of complicating Ivy's
runtime code as these extra generic type parameters had to be specified
as <any> throughout the codebase. *DefInternal types were introduced
previously to mitigate this issue, but that's the wrong way to solve
the problem.

This commit returns *Def types to their original form, with no metadata
attached. Instead, new *DefWithMeta types are introduced that alias the
plain definition types and add extra generic parameters. This way the
only code that needs to deal with the extra metadata parameters is the
compiler code that reads and writes them - the existence of this metadata
is transparent to the runtime, as it should be.

PR Close 
2018-10-04 10:11:17 -07:00
Miško Hevery
d5bd86ae5d fix(ivy): don't accidently read the inherited definition ()
Create getter methods `getXXXDef` for each definition which
uses `hasOwnProperty` to verify that we don't accidently read form the
parent class.

Fixes: 
Fixes: 

PR Close 
2018-09-11 07:09:38 -07:00
Miško Hevery
116946fb11 style: tslint enforces no debugger statements left behind ()
PR Close 
2018-08-16 16:00:22 -07:00
Greg Magolan
9605456b66 build: refactor ambient node & jasmine types so they are only included where needed ()
PR Close 
2018-08-16 13:46:43 -07:00
Victor Berchet
1f1103913a refactor(ivy): cleanup the public API for core/testing ()
PR Close 
2018-08-15 09:53:17 -07:00
Victor Berchet
14ac7ad6b4 feat(ivy): implement TestBed ()
PR Close 
2018-08-14 11:58:47 -07:00
Victor Berchet
85106375ac refactor(ivy): misc cleanup ()
PR Close 
2018-08-14 11:58:47 -07:00
Igor Minar
74518c4b2e style: fix whitespace and indentation in the testing guide ()
PR Close 
2018-08-08 13:11:15 -07:00
JiaLi.Passion
ebf508fcd0 docs: add docs for fakeAsync test with custom macroTask in aio ()
PR Close 
2018-08-08 13:11:15 -07:00
Miško Hevery
6e2a1877ab refactor(core): remove withBody from public testing API ()
PR Close 
2018-07-31 15:09:32 -07:00
George Kalpakas
342678486d test: fix typings for DoneFn ()
This also fixes CI tests, which were accidentally broken in .

PR Close 
2018-07-27 11:13:32 -07:00
Miško Hevery
e1c6fd5453 Revert "feat(core): add support for using async/await with Jasmine" ()
This reverts commit f6829aba55e07609e312b4f67dbc9dbbf36e4e46.

PR Close 
2018-07-25 11:44:56 -07:00
George Kalpakas
e01b539ee5 refactor: infer type for it() assertion functions ()
PR Close 
2018-07-06 13:48:02 -07:00
George Kalpakas
00c110b055 build: upgrade jasmine (and related typings) to latest version ()
With these changes, the types are a little stricter now and also not
compatible with Protractor's jasmine-like syntax. So, we have to also
use `@types/jasminewd2` for e2e tests (but not for non-e2e tests).

I also had to "augment" `@types/jasminewd2`, because the latest
typings from [DefinitelyTyped][1] do not reflect the fact that the
`jasminewd2` version (v2.1.0) currently used by Protractor supports
passing a `done` callback to a spec.

[1]: 566e039485/types/jasminewd2/index.d.ts (L9-L15)

Fixes 
Closes 

PR Close 
2018-07-06 13:48:02 -07:00
Miško Hevery
71100e6d72 feat(core): add support for using async/await with Jasmine ()
Example:
```
it('...', await(async() => {
  doSomething();
  await asyncFn();
  doSomethingAfter();
}));
```

PR Close 
2018-06-28 14:59:48 -07:00
Rado Kirov
c95437f15d build(bazel): Turning on strictPropertyInitialization for Angular. ()
All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close 
2018-06-25 07:57:13 -07:00
Alex Rickabaugh
27bc7dcb43 feat(ivy): ngtsc compiles @Component, @Directive, @NgModule ()
This change supports compilation of components, directives, and modules
within ngtsc. Support is not complete, but is enough to compile and test
//packages/core/test/bundling/todo in full AOT mode. Code size benefits
are not yet achieved as //packages/core itself does not get compiled, and
some decorators (e.g. @Input) are not stripped, leading to unwanted code
being retained by the tree-shaker. This will be improved in future commits.

PR Close 
2018-06-14 14:36:45 -07:00
Pete Bacon Darwin
e6516b0229 docs: fix invalid headings ()
PR Close 
2018-06-13 16:47:40 -07:00
cexbrayat
41cd8f3efb refactor(core): use Partial<T> for MetadataOverride ()
Allows to write:

const fixture = TestBed
      .overridePipe(DisplayNamePipe, { set: { pure: false } })
      .createComponent(MenuComponent);

when you only want to set the `pure` metadata,
instead of currently:

const fixture = TestBed
      .overridePipe(DisplayNamePipe, { set: { name: 'displayName', pure: false } })
      .createComponent(MenuComponent);

which forces you to redefine the name of the pipe even if it is useless.

Fixes 

PR Close 
2018-05-29 18:40:05 -04:00
Pete Bacon Darwin
4b96a58c5a docs: remove all deprecated @stable jsdoc tags ()
These are no longer needed as stable docs are computed as those that
do not have `@experimental` or `@deprecated` tags.

PR Close 
2018-04-10 21:49:32 -07:00
Pete Bacon Darwin
7dc150c1e8 docs(core): migrate @whatItDoes tags to the description ()
We get the overview for the doc by splitting off the first
paragraph.

PR Close 
2018-04-05 09:26:24 -07:00
JiaLi.Passion
c560423b52 build: upgrade zone.js ()
PR Close 
2018-04-04 08:24:02 -07:00
Miško Hevery
55c9fb298f test(ivy): create todo app in ivy ()
PR Close 
2018-04-02 15:49:48 -07:00
Igor Minar
7d095b96cd fix: correct several esm2015 entry-points in package.jsons ()
PR Close 
2018-03-20 13:30:08 -07:00
Igor Minar
b43f8bc7d3 feat(core): upgrade rxjs to 6.0.0-alpha.4 ()
PR Close 
2018-03-19 21:51:51 -07:00
Igor Minar
ce63dc6f95 feat: update the package output of build.sh to APF v6 ()
PR Close 
2018-03-18 09:33:51 -07:00
Alex Eagle
88b3198c80 feat(bazel): change ng_package rule to APF v6 ()
Angular Package Format v6 stops bundling files in the esm5 and esm2015
directories, now that Webpack 4 can tree-shake per-file.

Adds some missing files like package.json to make packages closer to
what we publish today.

Refactor ng_package to be a type of npm_package and re-use the packaging
action from that rule.

PR Close 
2018-03-15 11:38:31 -07:00
Alex Rickabaugh
db56836425 feat: tree-shakeable providers API updates ()
Rename @Injectable({scope -> providedIn}).

Instead of {providedIn: APP_ROOT_SCOPE}, accept {providedIn: 'root'}.
Also, {providedIn: null} implies the injectable should not be added
to any scope.

PR Close 
2018-03-13 09:28:05 -07:00
Chuck Jazdzewski
8449eb8d62 build: upgrade to TypeScript 2.7 ()
Fixes: 

PR Close 
2018-03-12 09:27:23 -07:00