build: update jasmine to 3.5 (#34625)
1. update jasmine to 3.5 2. update @types/jasmine to 3.5 3. update @types/jasminewd2 to 2.0.8 Also fix several cases, the new jasmine 3 will help to create test cases correctly, such as in the `jasmine 2.x` version, the following case will pass ``` expect(1 == 2); ``` But in jsamine 3, the case will need to be ``` expect(1 == 2).toBeTrue(); ``` PR Close #34625
This commit is contained in:

committed by
Kara Erickson

parent
db4a448439
commit
ef4736d052
@ -95,7 +95,7 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
// The "test" compilation result is just the name of the decorator being compiled
|
||||
// (suffixed with `(compiled)`)
|
||||
handler.compile.and.callFake((decl: ts.Declaration, analysis: any) => {
|
||||
(handler.compile as any).and.callFake((decl: ts.Declaration, analysis: any) => {
|
||||
logs.push(`compile: ${(decl as any).name.text}@${analysis.decoratorName} (resolved: ${
|
||||
analysis.resolved})`);
|
||||
return `@${analysis.decoratorName} (compiled)`;
|
||||
@ -183,7 +183,7 @@ runInEachFileSystem(() => {
|
||||
it('should call detect on the decorator handlers with each class from the parsed file',
|
||||
() => {
|
||||
expect(testHandler.detect).toHaveBeenCalledTimes(5);
|
||||
expect(testHandler.detect.calls.allArgs().map(args => args[1])).toEqual([
|
||||
expect(testHandler.detect.calls.allArgs().map((args: any[]) => args[1])).toEqual([
|
||||
null,
|
||||
jasmine.arrayContaining([jasmine.objectContaining({name: 'Component'})]),
|
||||
jasmine.arrayContaining([jasmine.objectContaining({name: 'Directive'})]),
|
||||
|
@ -34,9 +34,9 @@ describe('ClusterExecutor', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
masterRunSpy = spyOn(ClusterMaster.prototype, 'run')
|
||||
.and.returnValue(Promise.resolve('CusterMaster#run()'));
|
||||
.and.returnValue(Promise.resolve('CusterMaster#run()' as any));
|
||||
workerRunSpy = spyOn(ClusterWorker.prototype, 'run')
|
||||
.and.returnValue(Promise.resolve('CusterWorker#run()'));
|
||||
.and.returnValue(Promise.resolve('CusterWorker#run()' as any));
|
||||
createTaskCompletedCallback = jasmine.createSpy('createTaskCompletedCallback');
|
||||
|
||||
mockLogger = new MockLogger();
|
||||
|
@ -38,7 +38,7 @@ runInEachFileSystem(() => {
|
||||
initMockFileSystem(fs, testFiles);
|
||||
|
||||
// Force single-process execution in unit tests by mocking available CPUs to 1.
|
||||
spyOn(os, 'cpus').and.returnValue([{model: 'Mock CPU'}]);
|
||||
spyOn(os, 'cpus').and.returnValue([{ model: 'Mock CPU' } as any]);
|
||||
});
|
||||
|
||||
it('should run ngcc without errors for esm2015', () => {
|
||||
@ -962,7 +962,8 @@ runInEachFileSystem(() => {
|
||||
.toMatch(ANGULAR_CORE_IMPORT_REGEX);
|
||||
|
||||
// Copies over files (unchanged) that did not need compiling
|
||||
expect(fs.exists(_(`/node_modules/@angular/common/__ivy_ngcc__/esm5/src/version.js`)));
|
||||
expect(fs.exists(_(`/node_modules/@angular/common/__ivy_ngcc__/esm5/src/version.js`)))
|
||||
.toBeTrue();
|
||||
expect(fs.readFile(_(`/node_modules/@angular/common/__ivy_ngcc__/esm5/src/version.js`)))
|
||||
.toEqual(fs.readFile(_(`/node_modules/@angular/common/esm5/src/version.js`)));
|
||||
|
||||
|
@ -66,6 +66,9 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
spyOn(lockFile, 'read').and.callFake(() => {
|
||||
log.push('read() => ' + lockFileContents);
|
||||
if (lockFileContents === null) {
|
||||
throw {code: 'ENOENT'};
|
||||
}
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
@ -99,6 +102,9 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
spyOn(lockFile, 'read').and.callFake(() => {
|
||||
log.push('read() => ' + lockFileContents);
|
||||
if (lockFileContents === null) {
|
||||
throw {code: 'ENOENT'};
|
||||
}
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
@ -148,6 +154,9 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
spyOn(lockFile, 'read').and.callFake(() => {
|
||||
log.push('read() => ' + lockFileContents);
|
||||
if (lockFileContents === null) {
|
||||
throw {code: 'ENOENT'};
|
||||
}
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
@ -167,4 +176,4 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ describe('unlocker', () => {
|
||||
it('should attach a handler to the `disconnect` event', () => {
|
||||
spyOn(process, 'on');
|
||||
require('../../../src/locking/lock_file_with_child_process/unlocker');
|
||||
expect(process.on).toHaveBeenCalledWith('disconnect', jasmine.any(Function));
|
||||
// TODO: @JiaLiPassion, need to wait for @types/jasmine to handle the override case
|
||||
expect(process.on).toHaveBeenCalledWith('disconnect' as any, jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ runInEachFileSystem(() => {
|
||||
const config = new NgccConfiguration(fs, _('/project'));
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints: {[_('/project/node_modules/some_package/valid_entry_point')]: {ignore: true}}
|
||||
});
|
||||
} as any);
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
_('/project/node_modules/some_package/valid_entry_point'));
|
||||
@ -95,7 +95,8 @@ runInEachFileSystem(() => {
|
||||
esm2015: './some_other.js',
|
||||
};
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints: {[_('/project/node_modules/some_package/valid_entry_point')]: {override}}
|
||||
entryPoints: {[_('/project/node_modules/some_package/valid_entry_point')]: {override}},
|
||||
versionRange: '*'
|
||||
});
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
@ -145,7 +146,9 @@ runInEachFileSystem(() => {
|
||||
const override =
|
||||
JSON.parse(createPackageJson('missing_package_json', {excludes: ['name']}));
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints: {[_('/project/node_modules/some_package/missing_package_json')]: {override}}
|
||||
entryPoints:
|
||||
{[_('/project/node_modules/some_package/missing_package_json')]: {override}},
|
||||
versionRange: '*'
|
||||
});
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
@ -279,7 +282,8 @@ runInEachFileSystem(() => {
|
||||
]);
|
||||
const config = new NgccConfiguration(fs, _('/project'));
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints: {[_('/project/node_modules/some_package/missing_metadata')]: {}}
|
||||
entryPoints: {[_('/project/node_modules/some_package/missing_metadata')]: {}},
|
||||
versionRange: '*'
|
||||
});
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
@ -398,7 +402,7 @@ runInEachFileSystem(() => {
|
||||
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
|
||||
return fail(`Expected an entry point but got ${result}`);
|
||||
}
|
||||
entryPoint = result;
|
||||
entryPoint = result as any;
|
||||
});
|
||||
|
||||
it('should return `esm2015` format for `fesm2015` property', () => {
|
||||
|
Reference in New Issue
Block a user