/** * File source: https://bit.ly/3ukaHTz * * Feel free to let us know via PR, if you find something broken in this contract * file. */ import { pluginAdonisJS } from '@japa/plugin-adonisjs'; import { assert } from '@japa/assert'; import { apiClient } from '@japa/api-client'; import app from '@adonisjs/core/services/app'; import type { Config } from '@japa/runner/types'; import testUtils from '@adonisjs/core/services/test_utils'; import { fakeCsrfField } from './utils.js'; /* |-------------------------------------------------------------------------- | 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. | */ export const plugins: Config['plugins'] = [ assert(), apiClient(), pluginAdonisJS(app), ]; /* |-------------------------------------------------------------------------- | 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: Required> = { setup: [() => testUtils.db().migrate(), () => fakeCsrfField()], teardown: [], }; /* |-------------------------------------------------------------------------- | 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. */ // eslint-disable-next-line consistent-return export const configureSuite: Config['configureSuite'] = suite => { if (['browser', 'functional', 'e2e'].includes(suite.name)) { return suite.setup(() => testUtils.httpServer().start()); } };