Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!