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

284
Views
Prueba de llamadas de API de simulación de integración (POST)

Soy nuevo en las pruebas de mi proyecto. Quiero probar la API de llamada. He estado probando la API de llamada pero no tengo idea de cómo probar la llamada POST .

 export default { get: () => { return Promise.resolve({ data: [{ "id": "qcCK3SzECmaZAGRrHjaC", "status": "refused", "pct": 20, "amount": 200, "email": "a@a", "name": "test2", "vat": "40", "fileName": "preview-facture-free-201801-pdf-1.jpg", "date": "2002-02-02", "commentAdmin": "pas la bonne facture", "commentary": "test2", "type": "Restaurants et bars", "fileUrl": "https://firebasestorage.googleapis.com/v0/b/billable-677b6.a…f-1.jpg?alt=media&token=4df6ed2c-12c8-42a2-b013-346c1346f732" }] }) }, }

en la carpeta tests :

 import firebase from "../__mocks__/firebase" import BillsUI from "../views/BillsUI.js" describe("Given I am connected as Employee",()=>{ describe("When I navigate to bills page",()=>{ test("fetches bills from mock API GET", async () => { const getSpy = jest.spyOn(firebase, "get") const bills = await firebase.get() expect(getSpy).toHaveBeenCalledTimes(1) expect(bills.data.length).toBe(1) }) test("fetches bills from an API and fails with 404 message error", async () => { firebase.get.mockImplementationOnce(() => Promise.reject(new Error("Erreur 404")) ) const html = BillsUI({ error: "Erreur 404" }) document.body.innerHTML = html const message = await screen.getByText(/Erreur 404/) expect(message).toBeTruthy() }) test("fetches messages from an API and fails with 500 message error", async () => { firebase.get.mockImplementationOnce(() => Promise.reject(new Error("Erreur 500")) ) const html = BillsUI({ error: "Erreur 500" }) document.body.innerHTML = html const message = await screen.getByText(/Erreur 500/) expect(message).toBeTruthy() }) }) })

¿Así es como Mocking API obtiene y prueba alguna idea de cómo simular una llamada API POST?

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!