-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.js
42 lines (35 loc) · 1.07 KB
/
setup.js
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
38
39
40
41
42
const {
createContainer,
stopOldContainers,
waitForReady,
initializeServices,
getServices,
factoryConfig,
spinner,
} = require('./utils')
// ==========================================
// aws-sdk requires access and secret key
// ==========================================
process.env.AWS_ACCESS_KEY_ID = 'access-key'
process.env.AWS_SECRET_ACCESS_KEY = 'secret-key'
process.env.AWS_REGION = 'us-east-1'
process.env.AWS_ENDPOINT_URL = 'http://localhost:4566'
process.env.AWS_DYNAMODB_ENDPOINT_URL = 'http://localhost:4566'
async function main() {
spinner.start('Setup')
const config = await factoryConfig()
const services = getServices(config)
await stopOldContainers()
let { container } = await createContainer(config, services)
global.__JEST_LOCALSTACK__ = container
try {
await container.start()
await waitForReady(container, config)
await initializeServices(container, config, services)
spinner.stop()
} catch (error) {
spinner.warn('Error')
await stopOldContainers().then(() => Promise.reject(error))
}
}
module.exports = main