-
Notifications
You must be signed in to change notification settings - Fork 0
/
japaFile.ts
37 lines (32 loc) · 927 Bytes
/
japaFile.ts
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
import 'reflect-metadata'
import { join } from 'path'
import getPort from 'get-port'
import { configure } from 'japa'
import sourceMapSupport from 'source-map-support'
import execa from 'execa'
process.env.NODE_ENV = 'testing'
process.env.ADONIS_ACE_CWD = join(__dirname)
sourceMapSupport.install({ handleUncaughtExceptions: false })
async function runMigrations() {
await execa.node('ace', ['migration:run'], {
stdio: 'inherit',
})
}
async function rollbackMigrations() {
await execa.node('ace', ['migration:rollback'], {
stdio: 'inherit',
})
}
async function startHttpServer() {
const { Ignitor } = await import('@adonisjs/core/build/src/Ignitor')
process.env.PORT = String(await getPort())
await new Ignitor(__dirname).httpServer().start()
}
/**
* Configure test runner
*/
configure({
files: ['test/**/*.spec.ts'],
before: [runMigrations, startHttpServer],
after: [rollbackMigrations],
})