Skip to content

Coverage testing an API? #5473

Answered by hi-ogawa
rowanwins asked this question in Q&A
Apr 2, 2024 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

globalSetup runs in a main process while setupFiles runs in a same runtime as your test code, which is where coverage is taken. So you may try setupFiles, but its setup/teardown runs for each test file, so you might need to adjust your test structure.

Or as you noticed you could use supertest, which is a wrapper to launch server (inside test code) and write an request/response assertion in an opinionated manner, but I think what happens at lower level isn't so different from your style of running app.listen manually and writing assertion using fetch directly.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@rowanwins
Comment options

@hi-ogawa
Comment options

Answer selected by rowanwins
@rowanwins
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants