test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. |--------------------------------------------------------------------------
  3. | Tests
  4. |--------------------------------------------------------------------------
  5. |
  6. | The contents in this file boots the AdonisJS application and configures
  7. | the Japa tests runner.
  8. |
  9. | For the most part you will never edit this file. The configuration
  10. | for the tests can be controlled via ".adonisrc.json" and
  11. | "tests/bootstrap.ts" files.
  12. |
  13. */
  14. process.env.NODE_ENV = 'test'
  15. import 'reflect-metadata'
  16. import sourceMapSupport from 'source-map-support'
  17. import { Ignitor } from '@adonisjs/core/build/standalone'
  18. import { configure, processCliArgs, run, RunnerHooksHandler } from '@japa/runner'
  19. sourceMapSupport.install({ handleUncaughtExceptions: false })
  20. const kernel = new Ignitor(__dirname).kernel('test')
  21. kernel
  22. .boot()
  23. .then(() => import('./tests/bootstrap'))
  24. .then(({ runnerHooks, ...config }) => {
  25. const app: RunnerHooksHandler[] = [() => kernel.start()]
  26. configure({
  27. ...kernel.application.rcFile.tests,
  28. ...processCliArgs(process.argv.slice(2)),
  29. ...config,
  30. ...{
  31. importer: (filePath) => import(filePath),
  32. setup: app.concat(runnerHooks.setup),
  33. teardown: runnerHooks.teardown
  34. },
  35. cwd: kernel.application.appRoot
  36. })
  37. run()
  38. })