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

297
Views
Recibir un 'Error de tipo: axios.get.mockImplementationOnce no es una función' cuando se usa broma

Parece que no puedo entender por qué mis pruebas de broma arrojan este error.

TypeError: axios.get.mockImplementationOnce is not a function

Aquí está mi código:

 ./event.test.js import axios from "axios"; import {jest} from '@jest/globals'; import ip from '../utils/ipv4.js'; import dotenv from 'dotenv'; import getEventByTitle from './eventTesting' const result = dotenv.config({path: "../.env"}); if (result.error) throw result.error const localhost = (process.env.IS_LOCAL == 'true') ? true : false; const url = (localhost) ? `http://${ip}:${process.env.PORT}` : process.env.API_URL; // Mock axios function /* jest.mock("axios", () => ({ get: jest.fn(() => Promise.resolve({ data: {} })) })) */ jest.mock("axios") // ^^ BOTH MOCK ATTEMPTS DONT WORK ^^ // TEST SUITE test("Test imports", () => { expect(dotenv).toBeDefined() expect(ip).toBeDefined() expect(axios).toBeDefined() }) describe('Axios test with mocking', () => { test("Test GET event", async () => { const fakeResponse = { title: "Mitchell's Dorm Party", host: 2, description: "Come to my party tonight in Leavey", location_id: 1, time: new Date("2021-11-06 10:50:00 PST") } // TypeError: axios.get.mockImplementationOnce is not a function axios.get.mockImplementationOnce(() => Promise.resolve({ data: fakeResponse }) ) const result = await getEventByTitle("Mitchell's Dorm Party") expect(mockAxios.get).toHaveBeenCalledTimes(1); console.log(result) }) })

No estoy seguro de qué podría estar haciendo mal y ninguna de la documentación publicada en línea ha ayudado hasta ahora. Cualquier consejo sería realmente apreciado. ¡Gracias!

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!