test(core): run schematic tests with public migration collection (#30198)
572b54967c
changed how the schematic
tests are executed. Tests no longer use the schematic collection
that is also used by the CLI `ng update` command and therefore
the migration collection could technically be invalid.
In order to ensure that the public migration collection is guaranteed
to work and to avoid duplication within two schematic collections, the
changes are partially reverted and only the disabled `injectable-pipe`
schematic has its own collection.
PR Close #30198
This commit is contained in:
parent
4c12d742dc
commit
f094bb54a7
|
@ -3,7 +3,6 @@ load("//tools:defaults.bzl", "npm_package")
|
|||
exports_files([
|
||||
"tsconfig.json",
|
||||
"migrations.json",
|
||||
"test-migrations.json",
|
||||
])
|
||||
|
||||
npm_package(
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"schematics": {
|
||||
"migration-move-document": {
|
||||
"description": "Migrates DOCUMENT Injection token from platform-browser imports to common import",
|
||||
"factory": "./migrations/move-document/index"
|
||||
},
|
||||
"migration-static-queries": {
|
||||
"description": "Migrates ViewChild and ContentChild to explicit query timing",
|
||||
"factory": "./migrations/static-queries/index"
|
||||
},
|
||||
"migration-template-local-variables": {
|
||||
"description": "Warns developers if values are assigned to template variables",
|
||||
"factory": "./migrations/template-var-assignment/index"
|
||||
},
|
||||
"migration-injectable-pipe": {
|
||||
"description": "Migrates all Pipe classes so that they have an Injectable annotation",
|
||||
"factory": "./migrations/injectable-pipe/index"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,8 @@ ts_library(
|
|||
testonly = True,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
data = [
|
||||
"//packages/core/schematics:test-migrations.json",
|
||||
"test-migrations.json",
|
||||
"//packages/core/schematics:migrations.json",
|
||||
],
|
||||
deps = [
|
||||
"//packages/core/schematics/migrations/injectable-pipe",
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('injectable pipe migration', () => {
|
|||
let previousWorkingDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
|
||||
runner = new SchematicTestRunner('test', require.resolve('./test-migrations.json'));
|
||||
host = new TempScopedNodeJsSyncHost();
|
||||
tree = new UnitTestTree(new HostTree(host));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('move-document migration', () => {
|
|||
let previousWorkingDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
|
||||
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
|
||||
host = new TempScopedNodeJsSyncHost();
|
||||
tree = new UnitTestTree(new HostTree(host));
|
||||
|
||||
|
@ -151,5 +151,5 @@ describe('move-document migration', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
function runMigration() { runner.runSchematic('migration-move-document', {}, tree); }
|
||||
function runMigration() { runner.runSchematic('migration-v8-move-document', {}, tree); }
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('static-queries migration with template strategy', () => {
|
|||
let warnOutput: string[];
|
||||
|
||||
beforeEach(() => {
|
||||
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
|
||||
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
|
||||
host = new TempScopedNodeJsSyncHost();
|
||||
tree = new UnitTestTree(new HostTree(host));
|
||||
|
||||
|
@ -97,7 +97,7 @@ describe('static-queries migration with template strategy', () => {
|
|||
}
|
||||
|
||||
async function runMigration() {
|
||||
await runner.runSchematicAsync('migration-static-queries', {}, tree).toPromise();
|
||||
await runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
describe('ViewChild', () => {
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('static-queries migration with usage strategy', () => {
|
|||
afterAll(() => process.env['NG_STATIC_QUERY_USAGE_STRATEGY'] = '');
|
||||
|
||||
beforeEach(() => {
|
||||
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
|
||||
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
|
||||
host = new TempScopedNodeJsSyncHost();
|
||||
tree = new UnitTestTree(new HostTree(host));
|
||||
|
||||
|
@ -145,7 +145,7 @@ describe('static-queries migration with usage strategy', () => {
|
|||
}
|
||||
|
||||
async function runMigration() {
|
||||
await runner.runSchematicAsync('migration-static-queries', {}, tree).toPromise();
|
||||
await runner.runSchematicAsync('migration-v8-static-queries', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
function createQueryTests(queryType: 'ViewChild' | 'ContentChild') {
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('template variable assignment migration', () => {
|
|||
let warnOutput: string[];
|
||||
|
||||
beforeEach(() => {
|
||||
runner = new SchematicTestRunner('test', require.resolve('../test-migrations.json'));
|
||||
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
|
||||
host = new TempScopedNodeJsSyncHost();
|
||||
tree = new UnitTestTree(new HostTree(host));
|
||||
|
||||
|
@ -58,7 +58,9 @@ describe('template variable assignment migration', () => {
|
|||
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
|
||||
}
|
||||
|
||||
function runMigration() { runner.runSchematic('migration-template-local-variables', {}, tree); }
|
||||
function runMigration() {
|
||||
runner.runSchematic('migration-v8-template-local-variables', {}, tree);
|
||||
}
|
||||
|
||||
it('should warn for two-way data binding variable assignment', () => {
|
||||
writeFile('/index.ts', `
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// Migrations which are not publicly enabled but still run as part of tests need to
|
||||
// be part of a schematic collection in order to be able to run it.
|
||||
"schematics": {
|
||||
"migration-injectable-pipe": {
|
||||
"description": "Migrates all Pipe classes so that they have an Injectable annotation",
|
||||
"factory": "../migrations/injectable-pipe/index"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue