forked from kentcdodds/testing-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e-api.js
More file actions
37 lines (31 loc) · 916 Bytes
/
Copy pathe2e-api.js
File metadata and controls
37 lines (31 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const path = require('path')
const {apiPort, spawnPromise} = require('./e2e-shared')
const devMode = Boolean(JSON.parse(process.env.E2E_DEV || 'false'))
const serviceStartScriptName = devMode ? 'dev' : ''
const cwd = path.join(__dirname, '..')
const apiCwd = path.join(cwd, 'api')
const mongoPort = 27018
const mongoUri = `mongodb://localhost:${mongoPort}/conduit`
// start app server
const startApiCommand = {
script: `npm start ${serviceStartScriptName} --silent`,
message: '🔑 starting api server',
}
const stdio = process.env.STDIO || ['pipe', 'pipe', process.stderr]
spawnPromise(startApiCommand, {
cwd: apiCwd,
stdio,
env: Object.assign({}, process.env, {
MONGODB_URI: mongoUri,
MONGOD_DEBUG: true,
PORT: apiPort,
}),
}).promise.then(
() => {
console.log('🏁 api finished')
},
error => {
console.error('🚨 api failed')
console.error(error.stack)
},
)