Skip to content

Pactum and Fastify #101

Answered by leelaprasadv
leegee asked this question in Q&A
Dec 6, 2021 · 1 comments · 8 replies
Discussion options

You must be logged in to vote

Hi 👋,

Can you let me know which test runner are you using?
Does your setup require you to run server instances for every test? If not (assuming you might be using mocha), you can start your fastify server in a before() and stop it in an after() global hooks of mocha. This way you just have to run one instance of your server before all tests begin on a single port.

Ex: add a base.spec.js

const server = require('./path-to-fastify-server');

// global hooks
before( () => {
  server.start(); // start fastify server before tests
});

after( () => {
  server.stop(); // if implemented for graceful shutdown
});

Hope this helps!

Edited (07/02/22)

Use this package - https://www.npmjs.com/package/pa…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@ASaiAnudeep
Comment options

@leegee
Comment options

@ASaiAnudeep
Comment options

@leegee
Comment options

@ASaiAnudeep
Comment options

Answer selected by ASaiAnudeep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
3 participants