-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathsetup.ts
More file actions
45 lines (39 loc) · 1.19 KB
/
setup.ts
File metadata and controls
45 lines (39 loc) · 1.19 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
44
45
import type { Page } from 'puppeteer';
import { writeMultipleFiles } from '../../../utils/fs';
import { silentNg } from '../../../utils/process';
export async function libraryConsumptionSetup(): Promise<void> {
await silentNg('generate', 'library', 'my-lib');
// Force an external template
await writeMultipleFiles({
'projects/my-lib/src/lib/my-lib.html': `<p>my-lib works!</p>`,
'projects/my-lib/src/lib/my-lib.ts': `import { Component } from '@angular/core';
@Component({
selector: 'lib-my-lib',
templateUrl: './my-lib.html',
})
export class MyLibComponent {}`,
'./src/app/app.ts': `
import { Component } from '@angular/core';
import { MyLibComponent } from 'my-lib';
@Component({
selector: 'app-root',
template: '<lib-my-lib></lib-my-lib>',
imports: [MyLibComponent],
})
export class App {
title = 'test-project';
constructor() {
}
}
`,
});
}
export async function browserCheck(page: Page): Promise<void> {
await page.waitForFunction(
() =>
!!(globalThis as any).document
.querySelector('lib-my-lib p')
?.textContent?.includes('my-lib works!'),
{ timeout: 10000 },
);
}