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
|
* 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 {Console} from '@angular/core/src/console';
|
||||||
import {noComponentFactoryError} from '@angular/core/src/linker/component_factory_resolver';
|
import {noComponentFactoryError} from '@angular/core/src/linker/component_factory_resolver';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
@ -14,8 +14,12 @@ import {fixmeIvy} from '@angular/private/testing';
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
if (ivyEnabled) {
|
||||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
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 {
|
class DummyConsole implements Console {
|
||||||
@ -25,13 +29,12 @@ class DummyConsole implements Console {
|
|||||||
warn(message: string) { this.warnings.push(message); }
|
warn(message: string) { this.warnings.push(message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function declareTests({useJit}: {useJit: boolean}) {
|
function declareTests(config?: {useJit: boolean}) {
|
||||||
describe('@Component.entryComponents', function() {
|
describe('@Component.entryComponents', function() {
|
||||||
let console: DummyConsole;
|
let console: DummyConsole;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
console = new DummyConsole();
|
console = new DummyConsole();
|
||||||
TestBed.configureCompiler(
|
TestBed.configureCompiler({...config, providers: [{provide: Console, useValue: console}]});
|
||||||
{useJit: useJit, providers: [{provide: Console, useValue: console}]});
|
|
||||||
TestBed.configureTestingModule({declarations: [MainComp, ChildComp, NestedChildComp]});
|
TestBed.configureTestingModule({declarations: [MainComp, ChildComp, NestedChildComp]});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {CompilerConfig} from '@angular/compiler';
|
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 {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
|
||||||
import {getDebugContext} from '@angular/core/src/errors';
|
import {getDebugContext} from '@angular/core/src/errors';
|
||||||
import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver';
|
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');
|
const ANCHOR_ELEMENT = new InjectionToken('AnchorElement');
|
||||||
|
|
||||||
{
|
{
|
||||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
if (ivyEnabled) {
|
||||||
|
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
|
||||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
} 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() {
|
describe('integration tests', function() {
|
||||||
|
|
||||||
beforeEach(() => { TestBed.configureCompiler({useJit}); });
|
beforeEach(() => { TestBed.configureCompiler({...config}); });
|
||||||
|
|
||||||
describe('react to record changes', function() {
|
describe('react to record changes', function() {
|
||||||
it('should consume text node changes', () => {
|
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 {TestBed} from '@angular/core/testing';
|
||||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {fixmeIvy} from '@angular/private/testing';
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
|
|
||||||
{
|
{
|
||||||
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
|
if (ivyEnabled) {
|
||||||
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
|
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() {
|
describe('<ng-container>', function() {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureCompiler({useJit: useJit});
|
TestBed.configureCompiler({...config});
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
MyComp,
|
MyComp,
|
||||||
|
@ -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 {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 {Console} from '@angular/core/src/console';
|
||||||
import {InjectableDef, defineInjectable} from '@angular/core/src/di/defs';
|
import {InjectableDef, defineInjectable} from '@angular/core/src/di/defs';
|
||||||
import {NgModuleData} from '@angular/core/src/view/types';
|
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', () => {
|
describe('NgModule', () => {
|
||||||
let compiler: Compiler;
|
let compiler: Compiler;
|
||||||
let injector: Injector;
|
let injector: Injector;
|
||||||
@ -112,8 +116,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
console = new DummyConsole();
|
console = new DummyConsole();
|
||||||
TestBed.configureCompiler(
|
TestBed.configureCompiler({...config, providers: [{provide: Console, useValue: console}]});
|
||||||
{useJit: useJit, providers: [{provide: Console, useValue: console}]});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(inject([Compiler, Injector], (_compiler: Compiler, _injector: Injector) => {
|
beforeEach(inject([Compiler, Injector], (_compiler: Compiler, _injector: Injector) => {
|
||||||
|
@ -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 {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 {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule, By, DOCUMENT} from '@angular/platform-browser';
|
import {BrowserModule, By, DOCUMENT} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
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';
|
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();
|
declareTestsUsingBootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
function declareTests({useJit}: {useJit: boolean}) {
|
function declareTests(config?: {useJit: boolean}) {
|
||||||
// Place to put reproductions for regressions
|
// Place to put reproductions for regressions
|
||||||
describe('regressions', () => {
|
describe('regressions', () => {
|
||||||
|
|
||||||
beforeEach(() => { TestBed.configureTestingModule({declarations: [MyComp1, PlatformPipe]}); });
|
beforeEach(() => { TestBed.configureTestingModule({declarations: [MyComp1, PlatformPipe]}); });
|
||||||
|
|
||||||
describe('platform pipes', () => {
|
describe('platform pipes', () => {
|
||||||
beforeEach(() => { TestBed.configureCompiler({useJit: useJit}); });
|
beforeEach(() => { TestBed.configureCompiler({...config}); });
|
||||||
|
|
||||||
it('should overwrite them by custom pipes', () => {
|
it('should overwrite them by custom pipes', () => {
|
||||||
TestBed.configureTestingModule({declarations: [CustomPipe]});
|
TestBed.configureTestingModule({declarations: [CustomPipe]});
|
||||||
|
@ -6,16 +6,20 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {ComponentFixture, TestBed, getTestBed} from '@angular/core/testing';
|
||||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
import {DomSanitizer} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
import {DomSanitizer} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
||||||
import {fixmeIvy} from '@angular/private/testing';
|
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: ''})
|
@Component({selector: 'my-comp', template: ''})
|
||||||
@ -29,11 +33,11 @@ class OnPrefixDir {
|
|||||||
@Input() onclick: any;
|
@Input() onclick: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
function declareTests({useJit}: {useJit: boolean}) {
|
function declareTests(config?: {useJit: boolean}) {
|
||||||
describe('security integration tests', function() {
|
describe('security integration tests', function() {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureCompiler({useJit: useJit}).configureTestingModule({
|
TestBed.configureCompiler({...config}).configureTestingModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
SecuredComponent,
|
SecuredComponent,
|
||||||
OnPrefixDir,
|
OnPrefixDir,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user