Skip to content

Commit 31c1c75

Browse files
clydindgp1130
authored andcommitted
refactor(@angular-devkit/schematics): remove deprecated sync test helpers
BREAKING CHANGE Deprecated `SchematicTestRunner.runSchematic` and `SchematicTestRunner.runExternalSchematic` have been removed. Use `SchematicTestRunner.runSchematicAsync` or `SchematicTestRunner.runExternalSchematicAsync` instead. Note: this change only effects direct `@angular-devkit/schematics` users and not the application developers.
1 parent 2bac4a5 commit 31c1c75

File tree

2 files changed

+0
-63
lines changed

2 files changed

+0
-63
lines changed

etc/api/angular_devkit/schematics/testing/index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export declare class SchematicTestRunner {
55
constructor(_collectionName: string, collectionPath: string);
66
callRule(rule: Rule, tree: Tree, parentContext?: Partial<SchematicContext>): Observable<Tree>;
77
registerCollection(collectionName: string, collectionPath: string): void;
8-
runExternalSchematic<SchematicSchemaT>(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree): UnitTestTree;
98
runExternalSchematicAsync<SchematicSchemaT>(collectionName: string, schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Observable<UnitTestTree>;
10-
runSchematic<SchematicSchemaT>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): UnitTestTree;
119
runSchematicAsync<SchematicSchemaT>(schematicName: string, opts?: SchematicSchemaT, tree?: Tree): Observable<UnitTestTree>;
1210
}
1311

packages/angular_devkit/schematics/testing/schematic-test-runner.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,6 @@ export class SchematicTestRunner {
8989
.pipe(map(tree => new UnitTestTree(tree)));
9090
}
9191

92-
/**
93-
* @deprecated Since v8.0.0 - Use {@link SchematicTestRunner.runSchematicAsync} instead.
94-
* All schematics can potentially be async.
95-
* This synchronous variant will fail if the schematic, any of its rules, or any schematics
96-
* it calls are async.
97-
*/
98-
runSchematic<SchematicSchemaT>(
99-
schematicName: string,
100-
opts?: SchematicSchemaT,
101-
tree?: Tree,
102-
): UnitTestTree {
103-
const schematic = this._collection.createSchematic(schematicName, true);
104-
105-
let result: UnitTestTree | null = null;
106-
let error;
107-
const host = observableOf(tree || new HostTree);
108-
this._engineHost.clearTasks();
109-
110-
schematic.call(opts || {}, host, { logger: this._logger })
111-
.subscribe(t => result = new UnitTestTree(t), e => error = e);
112-
113-
if (error) {
114-
throw error;
115-
}
116-
117-
if (result === null) {
118-
throw new Error('Schematic is async, please use runSchematicAsync');
119-
}
120-
121-
return result;
122-
}
123-
12492
runExternalSchematicAsync<SchematicSchemaT>(
12593
collectionName: string,
12694
schematicName: string,
@@ -136,35 +104,6 @@ export class SchematicTestRunner {
136104
.pipe(map(tree => new UnitTestTree(tree)));
137105
}
138106

139-
/**
140-
* @deprecated Since v8.0.0 - Use {@link SchematicTestRunner.runExternalSchematicAsync} instead.
141-
* All schematics can potentially be async.
142-
* This synchronous variant will fail if the schematic, any of its rules, or any schematics
143-
* it calls are async.
144-
*/
145-
runExternalSchematic<SchematicSchemaT>(
146-
collectionName: string,
147-
schematicName: string,
148-
opts?: SchematicSchemaT,
149-
tree?: Tree,
150-
): UnitTestTree {
151-
const externalCollection = this._engine.createCollection(collectionName);
152-
const schematic = externalCollection.createSchematic(schematicName, true);
153-
154-
let result: UnitTestTree | null = null;
155-
const host = observableOf(tree || new HostTree);
156-
this._engineHost.clearTasks();
157-
158-
schematic.call(opts || {}, host, { logger: this._logger })
159-
.subscribe(t => result = new UnitTestTree(t));
160-
161-
if (result === null) {
162-
throw new Error('Schematic is async, please use runSchematicAsync');
163-
}
164-
165-
return result;
166-
}
167-
168107
callRule(rule: Rule, tree: Tree, parentContext?: Partial<SchematicContext>): Observable<Tree> {
169108
const context = this._engine.createContext({} as Schematic<{}, {}>, parentContext);
170109

0 commit comments

Comments
 (0)