1
- import { ng } from '../../../utils/process' ;
2
1
import { writeFile } from '../../../utils/fs' ;
2
+ import { ng } from '../../../utils/process' ;
3
+
4
+ export default async function ( ) {
5
+ await ng ( 'generate' , 'library' , 'my-lib' ) ;
6
+ await ng ( 'build' , 'my-lib' ) ;
3
7
4
- export default function ( ) {
5
- return ng ( 'generate' , 'library' , 'my-lib' )
6
- . then ( ( ) => ng ( 'build' , 'my-lib' ) )
7
- . then ( ( ) => writeFile ( './src/app/app.module.ts' , `
8
+ await writeFile ( './src/app/app.module.ts' , `
8
9
import { BrowserModule } from '@angular/platform-browser';
9
10
import { NgModule } from '@angular/core';
10
11
import { MyLibModule } from 'my-lib';
@@ -23,8 +24,9 @@ export default function () {
23
24
bootstrap: [AppComponent]
24
25
})
25
26
export class AppModule { }
26
- ` ) )
27
- . then ( ( ) => writeFile ( './src/app/app.component.ts' , `
27
+ ` ) ;
28
+
29
+ await writeFile ( './src/app/app.component.ts' , `
28
30
import { Component } from '@angular/core';
29
31
import { MyLibService } from 'my-lib';
30
32
@@ -39,9 +41,35 @@ export default function () {
39
41
console.log(myLibService);
40
42
}
41
43
}
42
- ` ) )
43
- // Check that the build succeeds both with named project, unnammed (should build app), and prod.
44
- . then ( ( ) => ng ( 'build' , 'test-project' ) )
45
- . then ( ( ) => ng ( 'build' ) )
46
- . then ( ( ) => ng ( 'build' , '--prod' ) ) ;
44
+ ` ) ;
45
+
46
+ await writeFile ( 'e2e/src/app.e2e-spec.ts' , `
47
+ import { browser, logging, element, by } from 'protractor';
48
+ import { AppPage } from './app.po';
49
+
50
+ describe('workspace-project App', () => {
51
+ let page: AppPage;
52
+
53
+ beforeEach(() => {
54
+ page = new AppPage();
55
+ });
56
+
57
+ it('should display text from library component', () => {
58
+ page.navigateTo();
59
+ expect(element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!');
60
+ });
61
+
62
+ afterEach(async () => {
63
+ // Assert that there are no errors emitted from the browser
64
+ const logs = await browser.manage().logs().get(logging.Type.BROWSER);
65
+ expect(logs).not.toContain(jasmine.objectContaining({
66
+ level: logging.Level.SEVERE,
67
+ }));
68
+ });
69
+ });
70
+ ` ) ;
71
+
72
+ // Check that the tests succeeds both with named project, unnammed (should test app), and prod.
73
+ await ng ( 'e2e' ) ;
74
+ await ng ( 'e2e' , 'test-project' , '--devServerTarget=test-project:serve:production' ) ;
47
75
}
0 commit comments