Skip to content

Testing exception in plugin #4573

Closed Answered by Uzlopak
onosendi asked this question in Q&A
Feb 7, 2023 · 1 comments · 9 replies
Discussion options

You must be logged in to vote

With tap it would be

await t.rejects(() => fastify.register(myPlugin, 'foo'), new Error('foo'))

You are using mocha/chai. So read the documentation of your test runner on how to test for promises and rejections.
e.g. https://www.chaijs.com/plugins/chai-as-promised/

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@onosendi
Comment options

@onosendi
Comment options

@Uzlopak
Comment options

@onosendi
Comment options

@onosendi
Comment options

Answer selected by onosendi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants