1 import { ChildProcessWithoutNullStreams } from 'child_process'
2 import { basename } from 'path'
3 import { setValue } from '@wdio/shared-store-service'
4 import { createScreenshotsDirectory } from './files'
5 import { runCommand, runServer } from './server'
7 let appInstance: number
8 let app: ChildProcessWithoutNullStreams
12 async function beforeLocalSuite (suite: any) {
13 const config = buildConfig(suite.file)
15 await runCommand('npm run clean:server:test -- ' + appInstance)
16 app = runServer(appInstance, config)
19 function afterLocalSuite () {
24 async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
25 createScreenshotsDirectory()
27 appInstance = capabilities['browserName'] === 'chrome'
31 emailPort = 1025 + appInstance
33 config.baseUrl = 'http://localhost:900' + appInstance
35 await setValue(config.baseUrl + '-emailPort', emailPort)
38 async function onBrowserStackPrepare () {
41 await runCommand('npm run clean:server:test -- ' + appInstance)
42 app = runServer(appInstance)
45 function onBrowserStackComplete () {
54 onBrowserStackPrepare,
55 onBrowserStackComplete
58 // ---------------------------------------------------------------------------
60 function buildConfig (suiteFile: string = undefined) {
61 const filename = basename(suiteFile)
63 if (filename === 'custom-server-defaults.e2e-spec.ts') {
67 download_enabled: false,
68 comments_enabled: false,
84 if (filename === 'signup.e2e-spec.ts') {
90 hostname: '127.0.0.1',