-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathforwardref-es2015.ts
More file actions
43 lines (38 loc) · 1.45 KB
/
forwardref-es2015.ts
File metadata and controls
43 lines (38 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { appendToFile, replaceInFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';
export default async function () {
// Update the application to use a forward reference
await replaceInFile(
'src/app/app.ts',
"import { Component, signal } from '@angular/core';",
"import { Component, Inject, Injectable, forwardRef, signal } from '@angular/core';",
);
await appendToFile('src/app/app.ts', '\n@Injectable() export class Lock { }\n');
await replaceInFile(
'src/app/app.ts',
'export class App {',
'export class App {\n constructor(@Inject(forwardRef(() => Lock)) lock: Lock) {}',
);
// Update the application's unit tests to include the new injectable
await replaceInFile(
'src/app/app.spec.ts',
"import { App } from './app';",
"import { App, Lock } from './app';",
);
await replaceInFile(
'src/app/app.spec.ts',
'TestBed.configureTestingModule({',
'TestBed.configureTestingModule({ providers: [Lock],',
);
// Execute the application's tests with emitDecoratorMetadata disabled (default)
await ng('test', '--no-watch');
// Turn on emitDecoratorMetadata
await replaceInFile(
'tsconfig.json',
'"experimentalDecorators": true',
'"experimentalDecorators": true, "emitDecoratorMetadata": true',
);
// Execute the application's tests with emitDecoratorMetadata enabled
await expectToFail(() => ng('test', '--no-watch'));
}