@@ -5,7 +5,7 @@ import { packages } from '../../../../lib/packages';
5
5
import { getGlobalVariable } from './env' ;
6
6
import { prependToFile , readFile , replaceInFile , writeFile } from './fs' ;
7
7
import { gitCommit } from './git' ;
8
- import { installWorkspacePackages } from './packages' ;
8
+ import { installPackage , installWorkspacePackages } from './packages' ;
9
9
import { exec , execAndWaitForOutputToMatch , git , ng } from './process' ;
10
10
11
11
export function updateJsonFile ( filePath : string , fn : ( json : any ) => any | void ) {
@@ -39,26 +39,28 @@ export async function prepareProjectForE2e(name) {
39
39
40
40
console . log ( `Project ${ name } created... Installing packages.` ) ;
41
41
await installWorkspacePackages ( ) ;
42
+ await installPackage ( 'puppeteer' ) ;
42
43
43
44
await ng ( 'generate' , 'e2e' , '--related-app-name' , name ) ;
44
45
45
- // Initialize protractor webdriver. Often fails the first time so attempt twice if necessary.
46
- // const webdriverCommand = exec.bind(
47
- // null,
48
- // 'webdriver-manager',
49
- // 'update',
50
- // '--standalone',
51
- // 'false',
52
- // '--gecko',
53
- // 'false',
54
- // '--versions.chrome',
55
- // '101.0.4951.41',
56
- // );
57
- // try {
58
- // await webdriverCommand();
59
- // } catch (e) {
60
- // await webdriverCommand();
61
- // }
46
+ // Initialize welenium webdrivers.
47
+ // Often fails the first time so attempt twice if necessary.
48
+ const webdriverCommand = exec . bind (
49
+ null ,
50
+ 'node_modules/protractor/bin/webdriver-manager' ,
51
+ 'update' ,
52
+ '--standalone' ,
53
+ 'false' ,
54
+ '--gecko' ,
55
+ 'false' ,
56
+ '--versions.chrome' ,
57
+ '101.0.4951.41' ,
58
+ ) ;
59
+ try {
60
+ await webdriverCommand ( ) ;
61
+ } catch ( e ) {
62
+ await webdriverCommand ( ) ;
63
+ }
62
64
63
65
await useCIChrome ( 'e2e' ) ;
64
66
await useCIChrome ( '' ) ;
@@ -209,7 +211,6 @@ export async function useCIChrome(projectDir: string = ''): Promise<void> {
209
211
const protractorConf = path . join ( projectDir , 'protractor.conf.js' ) ;
210
212
const karmaConf = path . join ( projectDir , 'karma.conf.js' ) ;
211
213
212
- const chromePath = require ( 'puppeteer' ) . executablePath ( ) ;
213
214
const protractorPath = require . resolve ( 'protractor' ) ;
214
215
const webdriverUpdatePath = require . resolve ( 'webdriver-manager/selenium/update-config.json' , {
215
216
paths : [ protractorPath ] ,
@@ -227,7 +228,7 @@ export async function useCIChrome(projectDir: string = ''): Promise<void> {
227
228
`browserName: 'chrome',
228
229
chromeOptions: {
229
230
args: ['--headless'],
230
- binary: String.raw\` ${ chromePath } \` ,
231
+ binary: require('puppeteer').executablePath() ,
231
232
}` ,
232
233
) ;
233
234
await replaceInFile (
@@ -239,7 +240,10 @@ export async function useCIChrome(projectDir: string = ''): Promise<void> {
239
240
240
241
// Use Puppeteer in karma if a config is found on the project.
241
242
if ( fs . existsSync ( karmaConf ) ) {
242
- await prependToFile ( karmaConf , `process.env.CHROME_BIN = String.raw\`${ chromePath } \`;` ) ;
243
+ await prependToFile (
244
+ karmaConf ,
245
+ `process.env.CHROME_BIN = require('puppeteer').executablePath();` ,
246
+ ) ;
243
247
await replaceInFile ( karmaConf , `browsers: ['Chrome']` , `browsers: ['ChromeHeadless']` ) ;
244
248
}
245
249
}
0 commit comments