1- import { ng } from '../../../utils/process' ;
21import { 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' ) ;
37
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' , `
89 import { BrowserModule } from '@angular/platform-browser';
910 import { NgModule } from '@angular/core';
1011 import { MyLibModule } from 'my-lib';
@@ -23,8 +24,9 @@ export default function () {
2324 bootstrap: [AppComponent]
2425 })
2526 export class AppModule { }
26- ` ) )
27- . then ( ( ) => writeFile ( './src/app/app.component.ts' , `
27+ ` ) ;
28+
29+ await writeFile ( './src/app/app.component.ts' , `
2830 import { Component } from '@angular/core';
2931 import { MyLibService } from 'my-lib';
3032
@@ -39,9 +41,35 @@ export default function () {
3941 console.log(myLibService);
4042 }
4143 }
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' ) ;
4775}
0 commit comments