diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-10 18:37:40 -0700 |
---|---|---|
committer | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-10 18:37:40 -0700 |
commit | 2ad43db1ed01fe0b5b116ddda1a5177c9f62c130 (patch) | |
tree | 8a6c6b551e7216d40c86e0954d828c783848a37b /bin/test.ts | |
parent | refactor: project maintenance (diff) | |
download | ferdium-server-2ad43db1ed01fe0b5b116ddda1a5177c9f62c130.tar.gz ferdium-server-2ad43db1ed01fe0b5b116ddda1a5177c9f62c130.tar.zst ferdium-server-2ad43db1ed01fe0b5b116ddda1a5177c9f62c130.zip |
updates
Diffstat (limited to 'bin/test.ts')
-rw-r--r-- | bin/test.ts | 42 |
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 | ||
13 | process.env.NODE_ENV = 'test' | 13 | process.env.NODE_ENV = 'test'; |
14 | 14 | ||
15 | import 'reflect-metadata' | 15 | import 'reflect-metadata'; |
16 | import { Ignitor, prettyPrintError } from '@adonisjs/core' | 16 | import { Ignitor, prettyPrintError } from '@adonisjs/core'; |
17 | import { configure, processCLIArgs, run } from '@japa/runner' | 17 | import { 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 | */ |
23 | const APP_ROOT = new URL('../', import.meta.url) | 23 | const 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 | */ |
29 | const IMPORTER = (filePath: string) => { | 29 | const 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 | ||
36 | new Ignitor(APP_ROOT, { importer: IMPORTER }) | 36 | new 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 | }); |