tethys.backend/test.ts

46 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2023-03-03 15:54:28 +00:00
/*
|--------------------------------------------------------------------------
| Tests
|--------------------------------------------------------------------------
|
| The contents in this file boots the AdonisJS application and configures
| the Japa tests runner.
|
| For the most part you will never edit this file. The configuration
| for the tests can be controlled via ".adonisrc.json" and
| "tests/bootstrap.ts" files.
|
*/
2023-05-09 12:43:16 +00:00
process.env.NODE_ENV = 'test';
2023-03-03 15:54:28 +00:00
2023-05-09 12:43:16 +00:00
import 'reflect-metadata';
import sourceMapSupport from 'source-map-support';
import { Ignitor } from '@adonisjs/core/build/standalone';
import { configure, processCliArgs, run, RunnerHooksHandler } from '@japa/runner';
2023-03-03 15:54:28 +00:00
2023-05-09 12:43:16 +00:00
sourceMapSupport.install({ handleUncaughtExceptions: false });
2023-03-03 15:54:28 +00:00
2023-05-09 12:43:16 +00:00
const kernel = new Ignitor(__dirname).kernel('test');
2023-03-03 15:54:28 +00:00
kernel
2023-05-09 12:43:16 +00:00
.boot()
.then(() => import('./tests/bootstrap'))
.then(({ runnerHooks, ...config }) => {
const app: RunnerHooksHandler[] = [() => kernel.start()];
2023-03-03 15:54:28 +00:00
2023-05-09 12:43:16 +00:00
configure({
...kernel.application.rcFile.tests,
...processCliArgs(process.argv.slice(2)),
...config,
...{
importer: (filePath) => import(filePath),
setup: app.concat(runnerHooks.setup),
teardown: runnerHooks.teardown,
},
cwd: kernel.application.appRoot,
});
2023-03-03 15:54:28 +00:00
2023-05-09 12:43:16 +00:00
run();
});