You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you for everything related to testdouble. I'm having some trouble regarding a esm import in a fastify project I've been working on.
Here's the example code. getByAuthorization is a function called inside the prehandler middleware of a fastify endpoint. And the issue is, the function is not replaced, without giving any error or indication of the reason.
test('should throw forbidden on wrong x-key',async(t)=>{awaitquibble.esm(path.join(path.resolve(''),'../src/models/application.js'),{getByAuthorization: asyncfunction(){returnnull},},)const{ statusCode, body }=awaitserver.inject({method: 'POST',url: '/v1/events',payload: [{name: 'non-existent',timestamp: Date.now()}],headers: {'x-key': v4(),'x-client-id': v4(),},})constresponse=JSON.parse(body)t.is(statusCode,403)t.is(response.error,'Forbidden')t.truthy(response.message.includes('Invalid authorization key'))})
The text was updated successfully, but these errors were encountered:
@anonrig you're import-ing the server before you're quibble.esm-ing, right? So that means that the server is importing application.js before you're quibble-ing, which means it gets the unimported version of the application. This would happen even if you use CJS.
To deal with that, await import the server after you quibble.esm. I may be misunderstanding, but I believe that's the problem.
BTW, td.replaceEsm is the same as quibble.esm. You don't really need to use quibble (although it's still fine).
Hi everyone!
First of all thank you for everything related to testdouble. I'm having some trouble regarding a esm import in a fastify project I've been working on.
Here's the example code. getByAuthorization is a function called inside the prehandler middleware of a fastify endpoint. And the issue is, the function is not replaced, without giving any error or indication of the reason.
The text was updated successfully, but these errors were encountered: