E2E GraphQL Testing with Supertest & Jest
Jan 1, 2022
I have used many testing frameworks over the years: Mocha, Sinon.js, Chai, Supertest, Jest etc. but at the end I settled to the Jest-Supertest combination.
Setup Server
Configure Jest
- Install jest dependencies: npm i -D jest @types/jest ts-jest
2. Create jest configuration file.
3. Add test script to the package.json file.
--runInBand: Running test synchronously.
--testTimeout 60000: Increase timeout duration to enable server start and close in time.
--detectOpenHandles: Use this flag to check if anything left open after the tests are finished.