build: upgrade jasmine (and related typings) to latest version (#19904)
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 #23952
Closes #24733
PR Close #19904
This commit is contained in:

committed by
Miško Hevery

parent
1e74ea9e60
commit
00c110b055
@ -20,7 +20,13 @@ import {ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/testing'
|
||||
let resourceLoader: MockResourceLoader;
|
||||
|
||||
beforeEach(() => {
|
||||
// Jasmine relies on methods on `Function.prototype`, so restore the prototype on the spy.
|
||||
// Work around for: https://github.com/jasmine/jasmine/issues/1573
|
||||
// TODO: Figure out a better way to retrieve the JIT sources, without spying on `Function`.
|
||||
const originalProto = ɵglobal.Function.prototype;
|
||||
jitSpy = spyOn(ɵglobal, 'Function').and.callThrough();
|
||||
ɵglobal.Function.prototype = originalProto;
|
||||
|
||||
resourceLoader = new MockResourceLoader();
|
||||
TestBed.configureCompiler({providers: [{provide: ResourceLoader, useValue: resourceLoader}]});
|
||||
});
|
||||
|
@ -35,12 +35,13 @@ function mockSystem(modules: {[module: string]: any}) {
|
||||
|
||||
it('loads a default factory by appending the factory suffix', async(() => {
|
||||
const loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
loader.load('test').then(contents => { expect(contents).toBe('test module factory'); });
|
||||
loader.load('test').then(
|
||||
contents => { expect(contents).toBe('test module factory' as any); });
|
||||
}));
|
||||
it('loads a named factory by appending the factory suffix', async(() => {
|
||||
const loader = new SystemJsNgModuleLoader(new Compiler());
|
||||
loader.load('test#Named').then(contents => {
|
||||
expect(contents).toBe('test NamedNgFactory');
|
||||
expect(contents).toBe('test NamedNgFactory' as any);
|
||||
});
|
||||
}));
|
||||
it('loads a named factory with a configured prefix and suffix', async(() => {
|
||||
@ -49,7 +50,7 @@ function mockSystem(modules: {[module: string]: any}) {
|
||||
factoryPathSuffix: '/suffixed',
|
||||
});
|
||||
loader.load('test#Named').then(contents => {
|
||||
expect(contents).toBe('test module factory');
|
||||
expect(contents).toBe('test module factory' as any);
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@ -315,7 +315,7 @@ class TestObj {
|
||||
// But we should still get an array of the right length based on function.length.
|
||||
expect(reflector.parameters(ChildWithCtorNoDecorator)).toEqual([
|
||||
undefined, undefined, undefined
|
||||
]);
|
||||
] as any[]); // TODO: Review use of `any` here (#19904)
|
||||
|
||||
expect(reflector.parameters(NoDecorators)).toEqual([]);
|
||||
expect(reflector.parameters(<any>{})).toEqual([]);
|
||||
|
@ -1203,8 +1203,8 @@ describe('di', () => {
|
||||
describe('@Attribute', () => {
|
||||
|
||||
it('should inject attribute', () => {
|
||||
let exist: string|undefined = 'wrong';
|
||||
let nonExist: string|undefined = 'wrong';
|
||||
let exist = 'wrong' as string | undefined;
|
||||
let nonExist = 'wrong' as string | undefined;
|
||||
|
||||
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
|
||||
if (rf & RenderFlags.Create) {
|
||||
@ -1221,8 +1221,8 @@ describe('di', () => {
|
||||
|
||||
// https://stackblitz.com/edit/angular-8ytqkp?file=src%2Fapp%2Fapp.component.ts
|
||||
it('should not inject attributes representing bindings and outputs', () => {
|
||||
let exist: string|undefined = 'wrong';
|
||||
let nonExist: string|undefined = 'wrong';
|
||||
let exist = 'wrong' as string | undefined;
|
||||
let nonExist = 'wrong' as string | undefined;
|
||||
|
||||
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
|
||||
if (rf & RenderFlags.Create) {
|
||||
@ -1238,8 +1238,8 @@ describe('di', () => {
|
||||
});
|
||||
|
||||
it('should not accidentally inject attributes representing bindings and outputs', () => {
|
||||
let exist: string|undefined = 'wrong';
|
||||
let nonExist: string|undefined = 'wrong';
|
||||
let exist = 'wrong' as string | undefined;
|
||||
let nonExist = 'wrong' as string | undefined;
|
||||
|
||||
const MyApp = createComponent('my-app', function(rf: RenderFlags, ctx: any) {
|
||||
if (rf & RenderFlags.Create) {
|
||||
@ -1415,7 +1415,7 @@ describe('di', () => {
|
||||
// so that we have smaller HelloWorld.
|
||||
(parent.tNode as{parent: any}).parent = undefined;
|
||||
|
||||
const injector = getOrCreateNodeInjector();
|
||||
const injector: any = getOrCreateNodeInjector(); // TODO: Review use of `any` here (#19904)
|
||||
expect(injector).not.toBe(null);
|
||||
} finally {
|
||||
leaveView(oldView);
|
||||
|
@ -259,7 +259,7 @@ describe('NgOnChangesFeature', () => {
|
||||
|
||||
it('correctly computes firstChange', () => {
|
||||
class MyDirective implements OnChanges {
|
||||
public log: Array<string|SimpleChange> = [];
|
||||
public log: Array<string|SimpleChange|undefined> = [];
|
||||
public valA: string = 'initValue';
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public valB !: string;
|
||||
|
@ -112,7 +112,7 @@ describe('elementProperty', () => {
|
||||
|
||||
class OtherDir {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
id !: boolean;
|
||||
id !: number;
|
||||
clickStream = new EventEmitter();
|
||||
|
||||
static ngDirectiveDef = defineDirective({
|
||||
@ -138,7 +138,7 @@ describe('elementProperty', () => {
|
||||
|
||||
class IdDir {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
idNumber !: number;
|
||||
idNumber !: string;
|
||||
|
||||
static ngDirectiveDef = defineDirective({
|
||||
type: IdDir,
|
||||
@ -347,15 +347,14 @@ describe('elementProperty', () => {
|
||||
}
|
||||
}
|
||||
|
||||
expect(renderToHtml(Template, {condition: true, id1: 'one', id2: 'two', id3: 'three'}, deps))
|
||||
expect(renderToHtml(Template, {condition: true, id1: 'one', id2: 'two', id3: 3}, deps))
|
||||
.toEqual(`<button iddir="">Click me</button><button id="two">Click me too</button>`);
|
||||
expect(idDir !.idNumber).toEqual('one');
|
||||
|
||||
expect(
|
||||
renderToHtml(Template, {condition: false, id1: 'four', id2: 'two', id3: 'three'}, deps))
|
||||
expect(renderToHtml(Template, {condition: false, id1: 'four', id2: 'two', id3: 3}, deps))
|
||||
.toEqual(`<button iddir="">Click me</button><button otherdir="">Click me too</button>`);
|
||||
expect(idDir !.idNumber).toEqual('four');
|
||||
expect(otherDir !.id).toEqual('three');
|
||||
expect(otherDir !.id).toEqual(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -293,11 +293,11 @@ describe('array literals', () => {
|
||||
const e0_ff =
|
||||
(v0: any, v1: any, v2: any, v3: any, v4: any, v5: any, v6: any, v7: any,
|
||||
v8: any) => ['start', v0, v1, v2, v3, v4, v5, v6, v7, v8, 'end'];
|
||||
const e0_ff_1 = (v: any) => { return {name: v}; };
|
||||
const e0_ff_1 = (v: any) => `modified_${v}`;
|
||||
|
||||
renderToHtml(Template, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives);
|
||||
/**
|
||||
* <my-comp [names]="['start', v0, v1, v2, v3, {name: v4}, v5, v6, v7, v8, 'end']">
|
||||
* <my-comp [names]="['start', v0, v1, v2, v3, `modified_${v4}`, v5, v6, v7, v8, 'end']">
|
||||
* </my-comp>
|
||||
*/
|
||||
function Template(rf: RenderFlags, c: any) {
|
||||
@ -315,17 +315,17 @@ describe('array literals', () => {
|
||||
}
|
||||
|
||||
expect(myComp !.names).toEqual([
|
||||
'start', 'a', 'b', 'c', 'd', {name: 'e'}, 'f', 'g', 'h', 'i', 'end'
|
||||
'start', 'a', 'b', 'c', 'd', 'modified_e', 'f', 'g', 'h', 'i', 'end'
|
||||
]);
|
||||
|
||||
renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], directives);
|
||||
expect(myComp !.names).toEqual([
|
||||
'start', 'a1', 'b', 'c', 'd', {name: 'e'}, 'f', 'g', 'h', 'i', 'end'
|
||||
'start', 'a1', 'b', 'c', 'd', 'modified_e', 'f', 'g', 'h', 'i', 'end'
|
||||
]);
|
||||
|
||||
renderToHtml(Template, ['a1', 'b', 'c', 'd', 'e5', 'f', 'g', 'h', 'i'], directives);
|
||||
expect(myComp !.names).toEqual([
|
||||
'start', 'a1', 'b', 'c', 'd', {name: 'e5'}, 'f', 'g', 'h', 'i', 'end'
|
||||
'start', 'a1', 'b', 'c', 'd', 'modified_e5', 'f', 'g', 'h', 'i', 'end'
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,7 @@ import {callMostRecentEventListenerHandler, compViewDef, createAndGetRootNodes,
|
||||
* We map addEventListener to the Zones internal name. This is because we want to be fast
|
||||
* and bypass the zone bookkeeping. We know that we can do the bookkeeping faster.
|
||||
*/
|
||||
const addEventListener = '__zone_symbol__addEventListener';
|
||||
const addEventListener = '__zone_symbol__addEventListener' as 'addEventListener';
|
||||
|
||||
{
|
||||
describe(`Component Views`, () => {
|
||||
|
@ -20,8 +20,8 @@ import {ARG_TYPE_VALUES, callMostRecentEventListenerHandler, checkNodeInlineOrDy
|
||||
* We map addEventListener to the Zones internal name. This is because we want to be fast
|
||||
* and bypass the zone bookkeeping. We know that we can do the bookkeeping faster.
|
||||
*/
|
||||
const addEventListener = '__zone_symbol__addEventListener';
|
||||
const removeEventListener = '__zone_symbol__removeEventListener';
|
||||
const addEventListener = '__zone_symbol__addEventListener' as 'addEventListener';
|
||||
const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEventListener';
|
||||
|
||||
{
|
||||
describe(`View Elements`, () => {
|
||||
|
@ -23,7 +23,7 @@ export const proxy: ClassDecorator = (t: any) => t;
|
||||
const _global = <any>(typeof window === 'undefined' ? global : window);
|
||||
|
||||
export const afterEach: Function = _global.afterEach;
|
||||
export const expect: (actual: any) => jasmine.Matchers = _global.expect;
|
||||
export const expect: <T>(actual: T) => jasmine.Matchers<T> = _global.expect;
|
||||
|
||||
const jsmBeforeEach = _global.beforeEach;
|
||||
const jsmDescribe = _global.describe;
|
||||
|
Reference in New Issue
Block a user