test(ivy): finish root cause analysis for @angular/core TestBed failing tests (#27510)
PR Close #27510
This commit is contained in:
parent
8fa7e93c30
commit
913563a41d
@ -9,7 +9,7 @@
|
|||||||
import {ApplicationRef, Component, DoCheck, NgModule, OnInit, TestabilityRegistry, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
import {ApplicationRef, Component, DoCheck, NgModule, OnInit, TestabilityRegistry, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||||
import {getTestBed} from '@angular/core/testing';
|
import {getTestBed} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {fixmeIvy, withBody} from '@angular/private/testing';
|
import {withBody} from '@angular/private/testing';
|
||||||
|
|
||||||
import {NgModuleFactory} from '../src/render3/ng_module_ref';
|
import {NgModuleFactory} from '../src/render3/ng_module_ref';
|
||||||
|
|
||||||
@ -35,21 +35,22 @@ ivyEnabled && describe('ApplicationRef bootstrap', () => {
|
|||||||
class MyAppModule {
|
class MyAppModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
it('should bootstrap hello world', withBody('<hello-world></hello-world>', async() => {
|
||||||
'should bootstrap hello world', withBody('<hello-world></hello-world>', async() => {
|
|
||||||
const MyAppModuleFactory = new NgModuleFactory(MyAppModule);
|
const MyAppModuleFactory = new NgModuleFactory(MyAppModule);
|
||||||
const moduleRef = await getTestBed().platform.bootstrapModuleFactory(
|
const moduleRef =
|
||||||
MyAppModuleFactory, {ngZone: 'noop'});
|
await getTestBed().platform.bootstrapModuleFactory(MyAppModuleFactory, {ngZone: 'noop'});
|
||||||
const appRef = moduleRef.injector.get(ApplicationRef);
|
const appRef = moduleRef.injector.get(ApplicationRef);
|
||||||
const helloWorldComponent = appRef.components[0].instance as HelloWorldComponent;
|
const helloWorldComponent = appRef.components[0].instance as HelloWorldComponent;
|
||||||
expect(document.body.innerHTML)
|
expect(document.body.innerHTML)
|
||||||
.toEqual('<hello-world><div>Hello World</div></hello-world>');
|
.toEqual(
|
||||||
|
'<hello-world ng-version="0.0.0-PLACEHOLDER"><div>Hello World</div></hello-world>');
|
||||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck']);
|
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck']);
|
||||||
|
|
||||||
helloWorldComponent.name = 'Mundo';
|
helloWorldComponent.name = 'Mundo';
|
||||||
appRef.tick();
|
appRef.tick();
|
||||||
expect(document.body.innerHTML)
|
expect(document.body.innerHTML)
|
||||||
.toEqual('<hello-world><div>Hello Mundo</div></hello-world>');
|
.toEqual(
|
||||||
|
'<hello-world ng-version="0.0.0-PLACEHOLDER"><div>Hello Mundo</div></hello-world>');
|
||||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck', 'DoCheck']);
|
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck', 'DoCheck']);
|
||||||
|
|
||||||
// Cleanup TestabilityRegistry
|
// Cleanup TestabilityRegistry
|
||||||
|
@ -33,8 +33,9 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
|
|||||||
})('foo', 'bar');
|
})('foo', 'bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy('FW-806: Ivy\'s TestBed implementation doesn\'t inject compiler-related tokens')
|
||||||
'should work with inject()', fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
|
.it('should work with inject()',
|
||||||
|
fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
|
||||||
expect(parser).toBeAnInstanceOf(Parser);
|
expect(parser).toBeAnInstanceOf(Parser);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
@ -69,8 +69,10 @@ function declareTests(config?: {useJit: boolean}) {
|
|||||||
expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
|
expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it(
|
fixmeIvy(
|
||||||
'should not be able to get components from a parent component (content hierarchy)', () => {
|
'FW-805: Ivy\'s implementation of ComponentFactoryResolver doesn\'t have checks present in the view engine')
|
||||||
|
.it('should not be able to get components from a parent component (content hierarchy)',
|
||||||
|
() => {
|
||||||
TestBed.overrideComponent(
|
TestBed.overrideComponent(
|
||||||
MainComp, {set: {template: '<child><nested></nested></child>'}});
|
MainComp, {set: {template: '<child><nested></nested></child>'}});
|
||||||
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
|
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
|
||||||
|
@ -1331,9 +1331,12 @@ function declareTests(config?: {useJit: boolean}) {
|
|||||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should support viewProviders', () => {
|
fixmeIvy(
|
||||||
|
'FW-804: Injection of view providers with the @Host annotation works differently in ivy')
|
||||||
|
.it('should support viewProviders', () => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [MyComp, DirectiveProvidingInjectableInView, DirectiveConsumingInjectable],
|
declarations:
|
||||||
|
[MyComp, DirectiveProvidingInjectableInView, DirectiveConsumingInjectable],
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
});
|
});
|
||||||
const template = `
|
const template = `
|
||||||
|
@ -745,8 +745,7 @@ function declareTests(config?: {useJit: boolean}) {
|
|||||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('FW-682: Compiler error handling')
|
it('should throw when the aliased provider does not exist', () => {
|
||||||
.it('should throw when the aliased provider does not exist', () => {
|
|
||||||
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||||
const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
|
const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
|
||||||
expect(() => injector.get('car')).toThrowError(e);
|
expect(() => injector.get('car')).toThrowError(e);
|
||||||
|
@ -75,9 +75,7 @@ function declareTests(config?: {useJit: boolean}) {
|
|||||||
expect(CountingPipe.calls).toBe(1);
|
expect(CountingPipe.calls).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
it('should only update the bound property when using asyncPipe - #15205', fakeAsync(() => {
|
||||||
.it('should only update the bound property when using asyncPipe - #15205',
|
|
||||||
fakeAsync(() => {
|
|
||||||
@Component({template: '<div myDir [a]="p | async" [b]="2"></div>'})
|
@Component({template: '<div myDir [a]="p | async" [b]="2"></div>'})
|
||||||
class MyComp {
|
class MyComp {
|
||||||
p = Promise.resolve(1);
|
p = Promise.resolve(1);
|
||||||
@ -99,8 +97,7 @@ function declareTests(config?: {useJit: boolean}) {
|
|||||||
|
|
||||||
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
|
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
|
||||||
const fixture = TestBed.createComponent(MyComp);
|
const fixture = TestBed.createComponent(MyComp);
|
||||||
const dir =
|
const dir = fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir;
|
||||||
fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir;
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(dir.setterCalls).toEqual({'a': null, 'b': 2});
|
expect(dir.setterCalls).toEqual({'a': null, 'b': 2});
|
||||||
|
@ -138,7 +138,9 @@ import {fixmeIvy} from '@angular/private/testing';
|
|||||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should not inject deps from sibling root elements', () => {
|
fixmeIvy(
|
||||||
|
'FW-807: NgModule injector doesn\'t report full search path if a token is not found')
|
||||||
|
.it('should not inject deps from sibling root elements', () => {
|
||||||
const rootElNodes = [
|
const rootElNodes = [
|
||||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||||
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
|
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
|
||||||
@ -181,7 +183,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
|||||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('unknown').it('should throw for missing dependencies', () => {
|
fixmeIvy('FW-807: NgModule injector don\'t report full search path if a token is not found')
|
||||||
|
.it('should throw for missing dependencies', () => {
|
||||||
expect(() => createAndGetRootNodes(compViewDef([
|
expect(() => createAndGetRootNodes(compViewDef([
|
||||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['nonExistingDep'])
|
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['nonExistingDep'])
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationInitStatus, Component, Directive, Injector, NgModule, NgZone, Pipe, PlatformRef, Provider, RendererFactory2, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDef as NgModuleDef, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core';
|
import {ApplicationInitStatus, Component, Directive, Injector, NgModule, NgZone, Pipe, PlatformRef, Provider, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDef as NgModuleDef, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core';
|
||||||
|
|
||||||
import {ComponentFixture} from './component_fixture';
|
import {ComponentFixture} from './component_fixture';
|
||||||
import {MetadataOverride} from './metadata_override';
|
import {MetadataOverride} from './metadata_override';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, Injector, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵAPP_ROOT as APP_ROOT, ɵDepFlags as DepFlags, ɵInjectableDef as InjectableDef, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵgetInjectableDef as getInjectableDef, ɵivyEnabled as ivyEnabled, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
import {ApplicationInitStatus, CompilerOptions, Component, Directive, Injector, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵAPP_ROOT as APP_ROOT, ɵDepFlags as DepFlags, ɵInjectableDef as InjectableDef, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetInjectableDef as getInjectableDef, ɵivyEnabled as ivyEnabled, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||||
|
|
||||||
import {AsyncTestCompleter} from './async_test_completer';
|
import {AsyncTestCompleter} from './async_test_completer';
|
||||||
import {ComponentFixture} from './component_fixture';
|
import {ComponentFixture} from './component_fixture';
|
||||||
@ -15,6 +15,7 @@ import {TestBedRender3, _getTestBedRender3} from './r3_test_bed';
|
|||||||
import {ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, TestBedStatic, TestComponentRenderer, TestModuleMetadata} from './test_bed_common';
|
import {ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, TestBedStatic, TestComponentRenderer, TestModuleMetadata} from './test_bed_common';
|
||||||
import {TestingCompiler, TestingCompilerFactory} from './test_compiler';
|
import {TestingCompiler, TestingCompilerFactory} from './test_compiler';
|
||||||
|
|
||||||
|
|
||||||
const UNDEFINED = new Object();
|
const UNDEFINED = new Object();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user