aboutsummaryrefslogtreecommitdiffstats
path: root/bin/test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'bin/test.ts')
-rw-r--r--bin/test.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/bin/test.ts b/bin/test.ts
index fe7e950..abdfb72 100644
--- a/bin/test.ts
+++ b/bin/test.ts
@@ -10,17 +10,17 @@
10| 10|
11*/ 11*/
12 12
13process.env.NODE_ENV = 'test' 13process.env.NODE_ENV = 'test';
14 14
15import 'reflect-metadata' 15import 'reflect-metadata';
16import { Ignitor, prettyPrintError } from '@adonisjs/core' 16import { Ignitor, prettyPrintError } from '@adonisjs/core';
17import { configure, processCLIArgs, run } from '@japa/runner' 17import { configure, processCLIArgs, run } from '@japa/runner';
18 18
19/** 19/**
20 * URL to the application root. AdonisJS need it to resolve 20 * URL to the application root. AdonisJS need it to resolve
21 * paths to file and directories for scaffolding commands 21 * paths to file and directories for scaffolding commands
22 */ 22 */
23const APP_ROOT = new URL('../', import.meta.url) 23const APP_ROOT = new URL('../', import.meta.url);
24 24
25/** 25/**
26 * The importer is used to import files in context of the 26 * The importer is used to import files in context of the
@@ -28,33 +28,33 @@ const APP_ROOT = new URL('../', import.meta.url)
28 */ 28 */
29const IMPORTER = (filePath: string) => { 29const IMPORTER = (filePath: string) => {
30 if (filePath.startsWith('./') || filePath.startsWith('../')) { 30 if (filePath.startsWith('./') || filePath.startsWith('../')) {
31 return import(new URL(filePath, APP_ROOT).href) 31 return import(new URL(filePath, APP_ROOT).href);
32 } 32 }
33 return import(filePath) 33 return import(filePath);
34} 34};
35 35
36new Ignitor(APP_ROOT, { importer: IMPORTER }) 36new Ignitor(APP_ROOT, { importer: IMPORTER })
37 .tap((app) => { 37 .tap(app => {
38 app.booting(async () => { 38 app.booting(async () => {
39 await import('#start/env') 39 await import('#start/env');
40 }) 40 });
41 app.listen('SIGTERM', () => app.terminate()) 41 app.listen('SIGTERM', () => app.terminate());
42 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate()) 42 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate());
43 }) 43 })
44 .testRunner() 44 .testRunner()
45 .configure(async (app) => { 45 .configure(async app => {
46 const { runnerHooks, ...config } = await import('../tests/bootstrap.js') 46 const { runnerHooks, ...config } = await import('../tests/bootstrap.js');
47 47
48 processCLIArgs(process.argv.splice(2)) 48 processCLIArgs(process.argv.splice(2));
49 configure({ 49 configure({
50 ...app.rcFile.tests, 50 ...app.rcFile.tests,
51 ...config, 51 ...config,
52 setup: runnerHooks.setup, 52 setup: runnerHooks.setup,
53 teardown: [...runnerHooks.teardown, () => app.terminate()], 53 teardown: [...runnerHooks.teardown, () => app.terminate()],
54 }) 54 });
55 }) 55 })
56 .run(() => run()) 56 .run(() => run())
57 .catch((error) => { 57 .catch(error => {
58 process.exitCode = 1 58 process.exitCode = 1;
59 prettyPrintError(error) 59 prettyPrintError(error);
60 }) 60 });