aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bootstrap.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bootstrap.ts')
-rw-r--r--tests/bootstrap.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/bootstrap.ts b/tests/bootstrap.ts
new file mode 100644
index 0000000..efd1d1f
--- /dev/null
+++ b/tests/bootstrap.ts
@@ -0,0 +1,83 @@
1/**
2 * File source: https://bit.ly/3ukaHTz
3 *
4 * Feel free to let us know via PR, if you find something broken in this contract
5 * file.
6 */
7
8import type { Config } from '@japa/runner';
9import TestUtils from '@ioc:Adonis/Core/TestUtils';
10import {
11 assert,
12 runFailedTests,
13 specReporter,
14 apiClient,
15} from '@japa/preset-adonis';
16import { fakeCsrfField } from './utils';
17
18/*
19|--------------------------------------------------------------------------
20| Japa Plugins
21|--------------------------------------------------------------------------
22|
23| Japa plugins allows you to add additional features to Japa. By default
24| we register the assertion plugin.
25|
26| Feel free to remove existing plugins or add more.
27|
28*/
29export const plugins: Config['plugins'] = [
30 assert(),
31 runFailedTests(),
32 apiClient(),
33];
34
35/*
36|--------------------------------------------------------------------------
37| Japa Reporters
38|--------------------------------------------------------------------------
39|
40| Japa reporters displays/saves the progress of tests as they are executed.
41| By default, we register the spec reporter to show a detailed report
42| of tests on the terminal.
43|
44*/
45export const reporters: Config['reporters'] = [specReporter()];
46
47/*
48|--------------------------------------------------------------------------
49| Runner hooks
50|--------------------------------------------------------------------------
51|
52| Runner hooks are executed after booting the AdonisJS app and
53| before the test files are imported.
54|
55| You can perform actions like starting the HTTP server or running migrations
56| within the runner hooks
57|
58*/
59export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
60 setup: [
61 () => TestUtils.ace().loadCommands(),
62 () => TestUtils.db().migrate(),
63 () => fakeCsrfField(),
64 ],
65 teardown: [],
66};
67
68/*
69|--------------------------------------------------------------------------
70| Configure individual suites
71|--------------------------------------------------------------------------
72|
73| The configureSuite method gets called for every test suite registered
74| within ".adonisrc.json" file.
75|
76| You can use this method to configure suites. For example: Only start
77| the HTTP server when it is a functional suite.
78*/
79export const configureSuite: Config['configureSuite'] = suite => {
80 if (suite.name === 'functional') {
81 suite.setup(() => TestUtils.httpServer().start());
82 }
83};