|
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
|
|
|
|
|
8
|
|
|
import type { Config } from '@japa/runner' |
|
9
|
|
|
import TestUtils from '@ioc:Adonis/Core/TestUtils' |
|
10
|
|
|
import { assert, runFailedTests, specReporter, apiClient } from '@japa/preset-adonis' |
|
11
|
|
|
|
|
12
|
|
|
/* |
|
13
|
|
|
|-------------------------------------------------------------------------- |
|
14
|
|
|
| Japa Plugins |
|
15
|
|
|
|-------------------------------------------------------------------------- |
|
16
|
|
|
| |
|
17
|
|
|
| Japa plugins allows you to add additional features to Japa. By default |
|
18
|
|
|
| we register the assertion plugin. |
|
19
|
|
|
| |
|
20
|
|
|
| Feel free to remove existing plugins or add more. |
|
21
|
|
|
| |
|
22
|
|
|
*/ |
|
23
|
|
|
export const plugins: Required<Config>['plugins'] = [assert(), runFailedTests(), apiClient()] |
|
24
|
|
|
|
|
25
|
|
|
/* |
|
26
|
|
|
|-------------------------------------------------------------------------- |
|
27
|
|
|
| Japa Reporters |
|
28
|
|
|
|-------------------------------------------------------------------------- |
|
29
|
|
|
| |
|
30
|
|
|
| Japa reporters displays/saves the progress of tests as they are executed. |
|
31
|
|
|
| By default, we register the spec reporter to show a detailed report |
|
32
|
|
|
| of tests on the terminal. |
|
33
|
|
|
| |
|
34
|
|
|
*/ |
|
35
|
|
|
export const reporters: Required<Config>['reporters'] = [specReporter()] |
|
36
|
|
|
|
|
37
|
|
|
/* |
|
38
|
|
|
|-------------------------------------------------------------------------- |
|
39
|
|
|
| Runner hooks |
|
40
|
|
|
|-------------------------------------------------------------------------- |
|
41
|
|
|
| |
|
42
|
|
|
| Runner hooks are executed after booting the AdonisJS app and |
|
43
|
|
|
| before the test files are imported. |
|
44
|
|
|
| |
|
45
|
|
|
| You can perform actions like starting the HTTP server or running migrations |
|
46
|
|
|
| within the runner hooks |
|
47
|
|
|
| |
|
48
|
|
|
*/ |
|
49
|
|
|
export const runnerHooks: Pick<Required<Config>, 'setup' | 'teardown'> = { |
|
50
|
|
|
setup: [() => TestUtils.ace().loadCommands()], |
|
51
|
|
|
teardown: [], |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/* |
|
55
|
|
|
|-------------------------------------------------------------------------- |
|
56
|
|
|
| Configure individual suites |
|
57
|
|
|
|-------------------------------------------------------------------------- |
|
58
|
|
|
| |
|
59
|
|
|
| The configureSuite method gets called for every test suite registered |
|
60
|
|
|
| within ".adonisrc.json" file. |
|
61
|
|
|
| |
|
62
|
|
|
| You can use this method to configure suites. For example: Only start |
|
63
|
|
|
| the HTTP server when it is a functional suite. |
|
64
|
|
|
*/ |
|
65
|
|
|
export const configureSuite: Required<Config>['configureSuite'] = (suite) => { |
|
66
|
|
|
if (suite.name === 'functional') { |
|
67
|
|
|
suite.setup(() => TestUtils.httpServer().start()) |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|