test(ivy): skip useJit tests with Ivy (#27067)
Currently the `useJit` option from `TestBed.configureCompiler` isn't supported. These changes rework the existing test suites not to pass in `useJit` when running with Ivy. PR Close #27067
This commit is contained in:
parent
ee12e725c0
commit
6574e61062
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {noComponentFactoryError} from '@angular/core/src/linker/component_factory_resolver';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
@ -14,8 +14,12 @@ import {fixmeIvy} from '@angular/private/testing';
|
|||
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
}
|
||||
|
||||
class DummyConsole implements Console {
|
||||
|
@ -25,13 +29,12 @@ class DummyConsole implements Console {
|
|||
warn(message: string) { this.warnings.push(message); }
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
describe('@Component.entryComponents', function() {
|
||||
let console: DummyConsole;
|
||||
beforeEach(() => {
|
||||
console = new DummyConsole();
|
||||
TestBed.configureCompiler(
|
||||
{useJit: useJit, providers: [{provide: Console, useValue: console}]});
|
||||
TestBed.configureCompiler({...config, providers: [{provide: Console, useValue: console}]});
|
||||
TestBed.configureTestingModule({declarations: [MainComp, ChildComp, NestedChildComp]});
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {CompilerConfig} from '@angular/compiler';
|
||||
import {Compiler, ComponentFactory, ComponentRef, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, SkipSelf, ViewRef} from '@angular/core';
|
||||
import {Compiler, ComponentFactory, ComponentRef, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, SkipSelf, ViewRef, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
|
||||
import {getDebugContext} from '@angular/core/src/errors';
|
||||
import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver';
|
||||
|
@ -30,16 +30,19 @@ import {stringify} from '../../src/util';
|
|||
const ANCHOR_ELEMENT = new InjectionToken('AnchorElement');
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
describe('integration tests', function() {
|
||||
|
||||
beforeEach(() => { TestBed.configureCompiler({useJit}); });
|
||||
beforeEach(() => { TestBed.configureCompiler({...config}); });
|
||||
|
||||
describe('react to record changes', function() {
|
||||
it('should consume text node changes', () => {
|
||||
|
|
|
@ -7,22 +7,26 @@
|
|||
*/
|
||||
|
||||
|
||||
import {AfterContentInit, AfterViewInit, Component, ContentChildren, Directive, Input, QueryList, ViewChildren} from '@angular/core';
|
||||
import {AfterContentInit, AfterViewInit, Component, ContentChildren, Directive, Input, QueryList, ViewChildren, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {fixmeIvy} from '@angular/private/testing';
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
describe('<ng-container>', function() {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureCompiler({useJit: useJit});
|
||||
TestBed.configureCompiler({...config});
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
MyComp,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, InjectionToken, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, Self, Type, forwardRef, getModuleFactory} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, InjectionToken, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, Self, Type, forwardRef, getModuleFactory, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {InjectableDef, defineInjectable} from '@angular/core/src/di/defs';
|
||||
import {NgModuleData} from '@angular/core/src/view/types';
|
||||
|
@ -99,12 +99,16 @@ class DummyConsole implements Console {
|
|||
}
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
describe('NgModule', () => {
|
||||
let compiler: Compiler;
|
||||
let injector: Injector;
|
||||
|
@ -112,8 +116,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
|
||||
beforeEach(() => {
|
||||
console = new DummyConsole();
|
||||
TestBed.configureCompiler(
|
||||
{useJit: useJit, providers: [{provide: Console, useValue: console}]});
|
||||
TestBed.configureCompiler({...config, providers: [{provide: Console, useValue: console}]});
|
||||
});
|
||||
|
||||
beforeEach(inject([Compiler, Injector], (_compiler: Compiler, _injector: Injector) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, ApplicationRef, Component, ComponentRef, ContentChild, Directive, ErrorHandler, EventEmitter, HostListener, InjectionToken, Injector, Input, NgModule, NgModuleRef, NgZone, Output, Pipe, PipeTransform, Provider, QueryList, Renderer2, SimpleChanges, TemplateRef, ViewChildren, ViewContainerRef, destroyPlatform} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, ApplicationRef, Component, ComponentRef, ContentChild, Directive, ErrorHandler, EventEmitter, HostListener, InjectionToken, Injector, Input, NgModule, NgModuleRef, NgZone, Output, Pipe, PipeTransform, Provider, QueryList, Renderer2, SimpleChanges, TemplateRef, ViewChildren, ViewContainerRef, destroyPlatform, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||
import {BrowserModule, By, DOCUMENT} from '@angular/platform-browser';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
|
@ -15,21 +15,25 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
|||
import {fixmeIvy} from '@angular/private/testing';
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
declareTestsUsingBootstrap();
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
// Place to put reproductions for regressions
|
||||
describe('regressions', () => {
|
||||
|
||||
beforeEach(() => { TestBed.configureTestingModule({declarations: [MyComp1, PlatformPipe]}); });
|
||||
|
||||
describe('platform pipes', () => {
|
||||
beforeEach(() => { TestBed.configureCompiler({useJit: useJit}); });
|
||||
beforeEach(() => { TestBed.configureCompiler({...config}); });
|
||||
|
||||
it('should overwrite them by custom pipes', () => {
|
||||
TestBed.configureTestingModule({declarations: [CustomPipe]});
|
||||
|
|
|
@ -6,16 +6,20 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, Directive, HostBinding, Input, NO_ERRORS_SCHEMA} from '@angular/core';
|
||||
import {Component, Directive, HostBinding, Input, NO_ERRORS_SCHEMA, ɵivyEnabled as ivyEnabled} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, getTestBed} from '@angular/core/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DomSanitizer} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
||||
import {fixmeIvy} from '@angular/private/testing';
|
||||
|
||||
{
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
if (ivyEnabled) {
|
||||
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||
} else {
|
||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'my-comp', template: ''})
|
||||
|
@ -29,11 +33,11 @@ class OnPrefixDir {
|
|||
@Input() onclick: any;
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
function declareTests(config?: {useJit: boolean}) {
|
||||
describe('security integration tests', function() {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureCompiler({useJit: useJit}).configureTestingModule({
|
||||
TestBed.configureCompiler({...config}).configureTestingModule({
|
||||
declarations: [
|
||||
SecuredComponent,
|
||||
OnPrefixDir,
|
||||
|
|
Loading…
Reference in New Issue