Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): run schematic tests with public migration collection #30198

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/schematics/BUILD.bazel
Expand Up @@ -3,7 +3,6 @@ load("//tools:defaults.bzl", "npm_package")
exports_files([
"tsconfig.json",
"migrations.json",
"test-migrations.json",
])

npm_package(
Expand Down
20 changes: 0 additions & 20 deletions packages/core/schematics/test-migrations.json

This file was deleted.

3 changes: 2 additions & 1 deletion packages/core/schematics/test/BUILD.bazel
Expand Up @@ -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",
Expand Down
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions packages/core/schematics/test/move_document_migration_spec.ts
Expand Up @@ -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));

Expand Down Expand Up @@ -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); }
});
Expand Up @@ -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));

Expand Down Expand Up @@ -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', () => {
Expand Down
Expand Up @@ -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));

Expand Down Expand Up @@ -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') {
Expand Down
Expand Up @@ -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));

Expand Down Expand Up @@ -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', `
Expand Down
10 changes: 10 additions & 0 deletions packages/core/schematics/test/test-migrations.json
@@ -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"
}
}
}