test(ivy): root cause analysis for platform-browser (#27460)
PR Close #27460
This commit is contained in:
parent
c07afd9db1
commit
9062b391a2
|
@ -160,7 +160,7 @@ function bootstrap(
|
|||
|
||||
afterEach(destroyPlatform);
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-553: TestBed is unaware of async compilation') &&
|
||||
it('should throw if bootstrapped Directive is not a Component',
|
||||
inject([AsyncTestCompleter], (done: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
|
@ -188,7 +188,7 @@ function bootstrap(
|
|||
});
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-553: TestBed is unaware of async compilation') &&
|
||||
it('should throw if no provider',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const logger = new MockConsole();
|
||||
|
|
|
@ -10,7 +10,7 @@ import {CompilerConfig, ResourceLoader} from '@angular/compiler';
|
|||
import {CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, Inject, Injectable, Injector, Input, NgModule, Optional, Pipe, SkipSelf, ɵstringify as stringify} from '@angular/core';
|
||||
import {TestBed, async, fakeAsync, getTestBed, inject, tick, withModule} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {fixmeIvy} from '@angular/private/testing';
|
||||
import {fixmeIvy, obsoleteInIvy} from '@angular/private/testing';
|
||||
|
||||
// Services, and components for the tests.
|
||||
|
||||
|
@ -251,7 +251,8 @@ class CompWithUrlTemplate {
|
|||
expect(compFixture.componentInstance).toBeAnInstanceOf(CompUsingModuleDirectiveAndPipe);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should use set up directives and pipes', () => {
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView') &&
|
||||
it('should use set up directives and pipes', () => {
|
||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||
const el = compFixture.debugElement;
|
||||
|
||||
|
@ -288,7 +289,7 @@ class CompWithUrlTemplate {
|
|||
expect(service.value).toEqual('real value');
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView') &&
|
||||
it('should use set up directives and pipes', withModule(moduleConfig, () => {
|
||||
const compFixture = TestBed.createComponent(CompUsingModuleDirectiveAndPipe);
|
||||
const el = compFixture.debugElement;
|
||||
|
@ -309,7 +310,7 @@ class CompWithUrlTemplate {
|
|||
TestBed.compileComponents();
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') && isBrowser &&
|
||||
fixmeIvy('FW-553: TestBed is unaware of async compilation') && isBrowser &&
|
||||
it('should allow to createSync components with templateUrl after explicit async compilation',
|
||||
() => {
|
||||
const fixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
|
@ -370,7 +371,8 @@ class CompWithUrlTemplate {
|
|||
.overrideDirective(
|
||||
SomeDirective, {set: {selector: '[someDir]', host: {'[title]': 'someProp'}}});
|
||||
});
|
||||
fixmeIvy('unknown') && it('should work', () => {
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView') &&
|
||||
it('should work', () => {
|
||||
const compFixture = TestBed.createComponent(SomeComponent);
|
||||
compFixture.detectChanges();
|
||||
expect(compFixture.debugElement.children[0].properties['title']).toEqual('hello');
|
||||
|
@ -385,7 +387,8 @@ class CompWithUrlTemplate {
|
|||
.overridePipe(SomePipe, {set: {name: 'somePipe'}})
|
||||
.overridePipe(SomePipe, {add: {pure: false}});
|
||||
});
|
||||
fixmeIvy('unknown') && it('should work', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should work', () => {
|
||||
const compFixture = TestBed.createComponent(SomeComponent);
|
||||
compFixture.detectChanges();
|
||||
expect(compFixture.nativeElement).toHaveText('transformed hello');
|
||||
|
@ -455,7 +458,8 @@ class CompWithUrlTemplate {
|
|||
expect(TestBed.get('a')).toBe('mockA: depValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support SkipSelf', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support SkipSelf', () => {
|
||||
@NgModule({
|
||||
providers: [
|
||||
{provide: 'a', useValue: 'aValue'},
|
||||
|
@ -466,13 +470,15 @@ class CompWithUrlTemplate {
|
|||
}
|
||||
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]});
|
||||
'a',
|
||||
{useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]});
|
||||
TestBed.configureTestingModule(
|
||||
{providers: [{provide: 'dep', useValue: 'parentDepValue'}]});
|
||||
|
||||
const compiler = TestBed.get(Compiler) as Compiler;
|
||||
const modFactory = compiler.compileModuleSync(MyModule);
|
||||
expect(modFactory.create(getTestBed()).injector.get('a')).toBe('mockA: parentDepValue');
|
||||
expect(modFactory.create(getTestBed()).injector.get('a'))
|
||||
.toBe('mockA: parentDepValue');
|
||||
});
|
||||
|
||||
it('should keep imported NgModules eager', () => {
|
||||
|
@ -495,7 +501,7 @@ class CompWithUrlTemplate {
|
|||
expect(someModule).toBeAnInstanceOf(SomeModule);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
obsoleteInIvy(`deprecated method, won't be reimplemented for Render3`) &&
|
||||
it('should keep imported NgModules lazy with deprecatedOverrideProvider', () => {
|
||||
let someModule: SomeModule|undefined;
|
||||
|
||||
|
@ -547,7 +553,8 @@ class CompWithUrlTemplate {
|
|||
});
|
||||
|
||||
describe('in Components', () => {
|
||||
fixmeIvy('unknown') && it('should support useValue', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support useValue', () => {
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [
|
||||
|
@ -564,7 +571,8 @@ class CompWithUrlTemplate {
|
|||
expect(ctx.debugElement.injector.get('a')).toBe('mockValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support useFactory', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support useFactory', () => {
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [
|
||||
|
@ -577,13 +585,14 @@ class CompWithUrlTemplate {
|
|||
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: ['dep']});
|
||||
const ctx =
|
||||
TestBed.configureTestingModule({declarations: [MyComp]}).createComponent(MyComp);
|
||||
const ctx = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.createComponent(MyComp);
|
||||
|
||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support @Optional without matches', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support @Optional without matches', () => {
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [
|
||||
|
@ -594,14 +603,16 @@ class CompWithUrlTemplate {
|
|||
}
|
||||
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new Optional(), 'dep']]});
|
||||
const ctx =
|
||||
TestBed.configureTestingModule({declarations: [MyComp]}).createComponent(MyComp);
|
||||
'a',
|
||||
{useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new Optional(), 'dep']]});
|
||||
const ctx = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.createComponent(MyComp);
|
||||
|
||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: null');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support Optional with matches', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support Optional with matches', () => {
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [
|
||||
|
@ -613,14 +624,16 @@ class CompWithUrlTemplate {
|
|||
}
|
||||
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new Optional(), 'dep']]});
|
||||
const ctx =
|
||||
TestBed.configureTestingModule({declarations: [MyComp]}).createComponent(MyComp);
|
||||
'a',
|
||||
{useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new Optional(), 'dep']]});
|
||||
const ctx = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.createComponent(MyComp);
|
||||
|
||||
expect(ctx.debugElement.injector.get('a')).toBe('mockA: depValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support SkipSelf', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support SkipSelf', () => {
|
||||
@Directive({
|
||||
selector: '[myDir]',
|
||||
providers: [
|
||||
|
@ -641,13 +654,16 @@ class CompWithUrlTemplate {
|
|||
}
|
||||
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]});
|
||||
'a',
|
||||
{useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]});
|
||||
const ctx = TestBed.configureTestingModule({declarations: [MyComp, MyDir]})
|
||||
.createComponent(MyComp);
|
||||
expect(ctx.debugElement.children[0].injector.get('a')).toBe('mockA: parentDepValue');
|
||||
expect(ctx.debugElement.children[0].injector.get('a'))
|
||||
.toBe('mockA: parentDepValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support multiple providers in a template', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should support multiple providers in a template', () => {
|
||||
@Directive({
|
||||
selector: '[myDir1]',
|
||||
providers: [
|
||||
|
@ -692,7 +708,8 @@ class CompWithUrlTemplate {
|
|||
constructor(@Inject('a') a: any, @Inject('b') b: any) {}
|
||||
}
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy(
|
||||
'FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should inject providers that were declared before it', () => {
|
||||
TestBed.overrideProvider(
|
||||
'b', {useFactory: (a: string) => `mockB: ${a}`, deps: ['a']});
|
||||
|
@ -702,7 +719,8 @@ class CompWithUrlTemplate {
|
|||
expect(ctx.debugElement.injector.get('b')).toBe('mockB: aValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy(
|
||||
'FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should inject providers that were declared after it', () => {
|
||||
TestBed.overrideProvider(
|
||||
'a', {useFactory: (b: string) => `mockA: ${b}`, deps: ['b']});
|
||||
|
@ -723,7 +741,7 @@ class CompWithUrlTemplate {
|
|||
});
|
||||
|
||||
describe('overrideTemplateUsingTestingModule', () => {
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should compile the template in the context of the testing module', () => {
|
||||
@Component({selector: 'comp', template: 'a'})
|
||||
class MyComponent {
|
||||
|
@ -752,7 +770,8 @@ class CompWithUrlTemplate {
|
|||
expect(testDir !.test).toBe('some prop');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should throw if the TestBed is already created', () => {
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should throw if the TestBed is already created', () => {
|
||||
@Component({selector: 'comp', template: 'a'})
|
||||
class MyComponent {
|
||||
}
|
||||
|
@ -764,7 +783,7 @@ class CompWithUrlTemplate {
|
|||
/Cannot override template when the test module has already been instantiated/);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') &&
|
||||
it('should reset overrides when the testing module is resetted', () => {
|
||||
@Component({selector: 'comp', template: 'a'})
|
||||
class MyComponent {
|
||||
|
@ -790,25 +809,27 @@ class CompWithUrlTemplate {
|
|||
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should use set up providers', fakeAsync(() => {
|
||||
fixmeIvy('FW-553: TestBed is unaware of async compilation') &&
|
||||
it('should use set up providers', fakeAsync(() => {
|
||||
TestBed.compileComponents();
|
||||
tick();
|
||||
const compFixture =
|
||||
TestBed.createComponent(CompWithUrlTemplate);
|
||||
const compFixture = TestBed.createComponent(CompWithUrlTemplate);
|
||||
expect(compFixture.nativeElement).toHaveText('Hello world!');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('useJit true', () => {
|
||||
beforeEach(() => TestBed.configureCompiler({useJit: true}));
|
||||
fixmeIvy('unknown') && it('should set the value into CompilerConfig',
|
||||
obsoleteInIvy('the Render3 compiler JiT mode is not configurable') &&
|
||||
it('should set the value into CompilerConfig',
|
||||
inject([CompilerConfig], (config: CompilerConfig) => {
|
||||
expect(config.useJit).toBe(true);
|
||||
}));
|
||||
});
|
||||
describe('useJit false', () => {
|
||||
beforeEach(() => TestBed.configureCompiler({useJit: false}));
|
||||
fixmeIvy('unknown') && it('should set the value into CompilerConfig',
|
||||
obsoleteInIvy('the Render3 compiler JiT mode is not configurable') &&
|
||||
it('should set the value into CompilerConfig',
|
||||
inject([CompilerConfig], (config: CompilerConfig) => {
|
||||
expect(config.useJit).toBe(false);
|
||||
}));
|
||||
|
@ -900,7 +921,7 @@ class CompWithUrlTemplate {
|
|||
{providers: [{provide: ResourceLoader, useValue: {get: resourceLoaderGet}}]});
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-553: TestBed is unaware of async compilation') &&
|
||||
it('should report an error for declared components with templateUrl which never call TestBed.compileComponents',
|
||||
() => {
|
||||
const itPromise = patchJasmineIt();
|
||||
|
@ -919,7 +940,8 @@ class CompWithUrlTemplate {
|
|||
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
|
||||
fixmeIvy(`FW-721: Bindings to unknown properties are not reported as errors`) &&
|
||||
it('should error on unknown bound properties on custom elements by default', () => {
|
||||
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
|
||||
class ComponentUsingInvalidProperty {
|
||||
|
|
Loading…
Reference in New Issue