2023-03-03 16:54:28 +01:00
|
|
|
/**
|
|
|
|
* File source: https://bit.ly/3ukaHTz
|
|
|
|
*
|
|
|
|
* Feel free to let us know via PR, if you find something broken in this contract
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
|
2024-04-25 15:17:22 +02:00
|
|
|
// import type { Config } from '@japa/runner';
|
|
|
|
import type { Config } from '@japa/runner/types';
|
|
|
|
// import TestUtils from '@ioc:Adonis/Core/TestUtils';
|
|
|
|
import testUtils from '@adonisjs/core/services/test_utils';
|
|
|
|
// import { assert, runFailedTests, specReporter, apiClient } from '@japa/preset-adonis';
|
|
|
|
|
|
|
|
import { assert } from '@japa/assert';
|
|
|
|
import { apiClient } from '@japa/api-client';
|
|
|
|
import { pluginAdonisJS } from '@japa/plugin-adonisjs';
|
|
|
|
import app from '@adonisjs/core/services/app';
|
2025-01-24 17:11:10 +01:00
|
|
|
import env from '#start/env'
|
2023-03-03 16:54:28 +01:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Japa Plugins
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Japa plugins allows you to add additional features to Japa. By default
|
|
|
|
| we register the assertion plugin.
|
|
|
|
|
|
|
|
|
| Feel free to remove existing plugins or add more.
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 15:17:22 +02:00
|
|
|
// export const plugins: Required<Config>['plugins'] = [assert(), runFailedTests(), apiClient()];
|
2025-01-24 17:11:10 +01:00
|
|
|
export const plugins: Config['plugins'] = [
|
|
|
|
assert(),
|
|
|
|
apiClient({
|
|
|
|
baseURL: `http://${env.get('HOST')}:${env.get('PORT')}`,
|
|
|
|
}),
|
|
|
|
pluginAdonisJS(app),
|
|
|
|
];
|
2023-03-03 16:54:28 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Japa Reporters
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Japa reporters displays/saves the progress of tests as they are executed.
|
|
|
|
| By default, we register the spec reporter to show a detailed report
|
|
|
|
| of tests on the terminal.
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 15:17:22 +02:00
|
|
|
// export const reporters: Required<Config>['reporters'] = [specReporter()];
|
|
|
|
export const reporters: Required<Config>['reporters'] = {
|
|
|
|
activated: ['spec'],
|
|
|
|
};
|
2023-03-03 16:54:28 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Runner hooks
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Runner hooks are executed after booting the AdonisJS app and
|
|
|
|
| before the test files are imported.
|
|
|
|
|
|
|
|
|
| You can perform actions like starting the HTTP server or running migrations
|
|
|
|
| within the runner hooks
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
export const runnerHooks: Pick<Required<Config>, 'setup' | 'teardown'> = {
|
2024-01-31 13:19:46 +01:00
|
|
|
setup: [
|
2025-01-24 17:11:10 +01:00
|
|
|
() => {
|
|
|
|
console.log('running before all the tests');
|
|
|
|
},
|
2024-04-25 15:17:22 +02:00
|
|
|
// () => testUtils.ace().loadCommands(),
|
|
|
|
() => testUtils.db().migrate(),
|
|
|
|
// () => testUtils.httpServer().start(),
|
2024-01-31 13:19:46 +01:00
|
|
|
],
|
2025-01-24 17:11:10 +01:00
|
|
|
teardown: [
|
|
|
|
() => {
|
|
|
|
console.log('running after all the tests');
|
|
|
|
},
|
|
|
|
],
|
2023-03-03 16:54:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Configure individual suites
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| The configureSuite method gets called for every test suite registered
|
|
|
|
| within ".adonisrc.json" file.
|
|
|
|
|
|
|
|
|
| You can use this method to configure suites. For example: Only start
|
|
|
|
| the HTTP server when it is a functional suite.
|
|
|
|
*/
|
|
|
|
export const configureSuite: Required<Config>['configureSuite'] = (suite) => {
|
|
|
|
if (suite.name === 'functional') {
|
2024-04-25 15:17:22 +02:00
|
|
|
suite.setup(() => testUtils.httpServer().start());
|
2023-03-03 16:54:28 +01:00
|
|
|
}
|
|
|
|
};
|