helper.js 704 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict'
  2. // This file contains code that we reuse
  3. // between our tests.
  4. const Fastify = require('fastify')
  5. const fp = require('fastify-plugin')
  6. const App = require('../app')
  7. // Fill in this config with all the configurations
  8. // needed for testing the application
  9. function config () {
  10. return {}
  11. }
  12. // automatically build and tear down our instance
  13. function build (t) {
  14. const app = Fastify()
  15. // fastify-plugin ensures that all decorators
  16. // are exposed for testing purposes, this is
  17. // different from the production setup
  18. app.register(fp(App), config())
  19. // tear down our app after we are done
  20. t.tearDown(app.close.bind(app))
  21. return app
  22. }
  23. module.exports = {
  24. config,
  25. build
  26. }