1 import { ChildProcessWithoutNullStreams } from 'child_process'
2 import { basename } from 'path'
3 import { runCommand, runServer } from './server'
4 import { setValue } from '@wdio/shared-store-service'
6 let appInstance: number
7 let app: ChildProcessWithoutNullStreams
11 async function beforeLocalSuite (suite: any) {
12 const config = buildConfig(suite.file)
14 await runCommand('npm run clean:server:test -- ' + appInstance)
15 app = runServer(appInstance, config)
18 function afterLocalSuite () {
23 async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
24 appInstance = capabilities['browserName'] === 'chrome'
28 emailPort = 1025 + appInstance
30 config.baseUrl = 'http://localhost:900' + appInstance
32 await setValue('emailPort', emailPort)
35 async function onBrowserStackPrepare () {
38 await runCommand('npm run clean:server:test -- ' + appInstance)
39 app = runServer(appInstance)
42 function onBrowserStackComplete () {
51 onBrowserStackPrepare,
52 onBrowserStackComplete
55 // ---------------------------------------------------------------------------
57 function buildConfig (suiteFile: string = undefined) {
58 const filename = basename(suiteFile)
60 if (filename === 'custom-server-defaults.e2e-spec.ts') {
64 download_enabled: false,
65 comments_enabled: false,
81 if (filename === 'signup.e2e-spec.ts') {
87 hostname: '127.0.0.1',