test(core): fix schematics calls to run synchronously (#34364)
Previously the calls to run the schematics were not being properly or consistently awaited in the tests. While this currently does not affect the tests' performance, this fix corrects the syntax and adds stability for future changes. PR Close #34364
This commit is contained in:
parent
6e7ca05efc
commit
3255d2b197
|
@ -160,6 +160,6 @@ describe('dynamic queries migration', () => {
|
|||
}
|
||||
|
||||
function runMigration() {
|
||||
runner.runSchematicAsync('migration-v9-dynamic-queries', {}, tree).toPromise();
|
||||
return runner.runSchematicAsync('migration-v9-dynamic-queries', {}, tree).toPromise();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -63,8 +63,8 @@ describe('Missing injectable migration', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
async function runMigration() {
|
||||
await runner.runSchematicAsync('migration-v9-missing-injectable', {}, tree).toPromise();
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v9-missing-injectable', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
describe('NgModule', () => createTests('NgModule', 'providers'));
|
||||
|
|
|
@ -230,6 +230,6 @@ describe('ModuleWithProviders migration', () => {
|
|||
}
|
||||
|
||||
function runMigration() {
|
||||
runner.runSchematicAsync('migration-v9-module-with-providers', {}, tree).toPromise();
|
||||
return runner.runSchematicAsync('migration-v9-module-with-providers', {}, tree).toPromise();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -165,6 +165,6 @@ describe('move-document migration', () => {
|
|||
}
|
||||
|
||||
function runMigration() {
|
||||
runner.runSchematicAsync('migration-v8-move-document', {}, tree).toPromise();
|
||||
return runner.runSchematicAsync('migration-v8-move-document', {}, tree).toPromise();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -100,8 +100,8 @@ describe('static-queries migration with template strategy', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
async function runMigration() {
|
||||
await runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
describe('ViewChild', () => {
|
||||
|
|
|
@ -172,8 +172,8 @@ describe('static-queries migration with usage strategy', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
async function runMigration() {
|
||||
await runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
function createQueryTests(queryType: 'ViewChild' | 'ContentChild') {
|
||||
|
|
|
@ -68,13 +68,12 @@ describe('Undecorated classes with DI migration', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
async function runMigration() {
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v9-undecorated-classes-with-di', {}, tree)
|
||||
.toPromise();
|
||||
}
|
||||
|
||||
function
|
||||
writeFakeAngular() {
|
||||
function writeFakeAngular() {
|
||||
writeFile('/node_modules/@angular/core/index.d.ts', `
|
||||
export declare class PipeTransform {}
|
||||
export declare class NgZone {}
|
||||
|
|
|
@ -22,7 +22,7 @@ export function createMigrationCompilerHost(
|
|||
const treeRelativePath = relative(basePath, fileName);
|
||||
const fakeOutput = fakeRead ? fakeRead(treeRelativePath) : null;
|
||||
const buffer = fakeOutput === null ? tree.read(treeRelativePath) : fakeOutput;
|
||||
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset which
|
||||
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
|
||||
// which breaks the CLI UpdateRecorder.
|
||||
// See: https://github.com/angular/angular/pull/30719
|
||||
return buffer ? buffer.toString().replace(/^\uFEFF/, '') : undefined;
|
||||
|
|
Loading…
Reference in New Issue