summaryrefslogtreecommitdiffstats
path: root/tests/bootstrap.ts
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2024-02-11 19:15:20 +0530
committerLibravatar Vijay A <vraravam@users.noreply.github.com>2024-02-13 06:59:44 +0530
commit8fec21d6bccfa778c14c1714d6444312e36fc3f1 (patch)
treecab910ad5048eece2d229648f2c17000ac86a44d /tests/bootstrap.ts
parentupdates (diff)
downloadferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.tar.gz
ferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.tar.zst
ferdium-server-03e8c2b08e08822bcd069ad482799eecf1ede777.zip
Diffstat (limited to 'tests/bootstrap.ts')
-rw-r--r--tests/bootstrap.ts42
1 files changed, 14 insertions, 28 deletions
diff --git a/tests/bootstrap.ts b/tests/bootstrap.ts
index 521f718..d152db0 100644
--- a/tests/bootstrap.ts
+++ b/tests/bootstrap.ts
@@ -5,14 +5,14 @@
5 * file. 5 * file.
6 */ 6 */
7 7
8import type { Config } from '@japa/runner'; 8import { pluginAdonisJS } from '@japa/plugin-adonisjs';
9import TestUtils from '@ioc:Adonis/Core/TestUtils'; 9
10import { 10import { assert } from '@japa/assert';
11 assert, 11import { apiClient } from '@japa/api-client';
12 runFailedTests, 12import app from '@adonisjs/core/services/app';
13 specReporter, 13import type { Config } from '@japa/runner/types';
14 apiClient, 14import testUtils from '@adonisjs/core/services/test_utils';
15} from '@japa/preset-adonis'; 15
16import { fakeCsrfField } from './utils.js'; 16import { fakeCsrfField } from './utils.js';
17 17
18/* 18/*
@@ -26,26 +26,15 @@ import { fakeCsrfField } from './utils.js';
26| Feel free to remove existing plugins or add more. 26| Feel free to remove existing plugins or add more.
27| 27|
28*/ 28*/
29
29export const plugins: Config['plugins'] = [ 30export const plugins: Config['plugins'] = [
30 assert(), 31 assert(),
31 runFailedTests(),
32 apiClient(), 32 apiClient(),
33 pluginAdonisJS(app),
33]; 34];
34 35
35/* 36/*
36|-------------------------------------------------------------------------- 37|--------------------------------------------------------------------------
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 38| Runner hooks
50|-------------------------------------------------------------------------- 39|--------------------------------------------------------------------------
51| 40|
@@ -57,11 +46,7 @@ export const reporters: Config['reporters'] = [specReporter()];
57| 46|
58*/ 47*/
59export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = { 48export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
60 setup: [ 49 setup: [() => testUtils.db().migrate(), () => fakeCsrfField()],
61 () => TestUtils.ace().loadCommands(),
62 () => TestUtils.db().migrate(),
63 () => fakeCsrfField(),
64 ],
65 teardown: [], 50 teardown: [],
66}; 51};
67 52
@@ -76,8 +61,9 @@ export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
76| You can use this method to configure suites. For example: Only start 61| You can use this method to configure suites. For example: Only start
77| the HTTP server when it is a functional suite. 62| the HTTP server when it is a functional suite.
78*/ 63*/
64// eslint-disable-next-line consistent-return
79export const configureSuite: Config['configureSuite'] = suite => { 65export const configureSuite: Config['configureSuite'] = suite => {
80 if (suite.name === 'functional') { 66 if (['browser', 'functional', 'e2e'].includes(suite.name)) {
81 suite.setup(() => TestUtils.httpServer().start()); 67 return suite.setup(() => testUtils.httpServer().start());
82 } 68 }
83}; 69};