Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
How do I get a nock test to pass with a post body?

I have:

it.only('should trigger the Partner Client Service on error', async () => {
            const partnerServiceScope = nock(PARTNER_SERVICE_URL)
                .post('/api/v1/webhooks/event', {
                    type: 'member_info_needed',
                    data: { user_id: 'user123' },
                })
                .reply(200, {})

            try {
                await eligibilityService.getEligibility('user123')
            } catch (e) {
                expect(partnerServiceScope.isDone()).toBeTruthy()
            }
        })

The getEligibility has:

    async getEligibility(userId: string): Promise<EligibilityForPayer> {
        const eligibilityRecord =
            await stuff(userId)

        if (!eligibilityRecord) {
            void this.partnerService.postPartnerServiceEvent({
                type: PartnerServiceEventType.MemberInfoNeeded,
                data: {
                    user_id: userId,
                },
            })

The this.partnerService.postPartnerServiceEvent has:

            const res: AxiosResponse<unknown> = await partnerServiceClient.post(
                '/api/v1/webhooks/event',
                partnerServiceEvent,
            )
            return res.data

I can see that the test gets there, but the test does not return truth. What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda