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

404
Views
Error en Jest Test con Vanilla Javascript: expect(jest.fn()).toBeCalledWith(...expected) Esperado: "click", Any<Function> Número de llamadas: 0

Parece que el método de clic no se activa. He intentado todo, agradecería que alguien sepa la respuesta. Recibo este error: expect(jest.fn()).toBeCalledWith(...expected)

Esperado: "clic", Cualquiera

Número de llamadas: 0

No estoy seguro de lo que estoy haciendo mal aquí. Alguien sabe cómo resolver este problema.

Aquí está mi archivo app.js

 function display() { displayTable.style.display = "block" obj.move.push(input.value); let bulldozerMove = obj.move[obj.move.length - 1]; let index = obj.initPos[obj.initPos.length - 1]; let direction = obj.initDir[obj.initDir.length - 1]; solution( grid, index, direction, bulldozerMove ); let newRow = displayTable.insertRow(-1); key.forEach((val) => { let insertData = obj[val]; for (let i = 0; i < 1; i++) { let newCell = document.createElement("td"); newCell.style.border = 'solid 1px black'; newCell.appendChild(document.createTextNode(insertData[insertData.length - 1])); newRow.appendChild(newCell); } tableBody.appendChild(newRow); }) displayTable.appendChild(tableBody); document.body.appendChild(displayTable); } function main(){ button.addEventListener("click", display);} main(); const exportFunctions = { getNextPos, solution, main, display }; module.exports = exportFunctions;

Aquí está mi archivo app.test.js

 const app = require('./app'); test("It should pass", () => { const instanceMock = jest.spyOn(app, "display"); button.addEventListener = jest .fn() .mockImplementationOnce((event, callback) => { callback(); }); app.main(); expect(button.addEventListener).toBeCalledWith( "click", expect.any(Function) ); expect(instanceMock).toBeCalledTimes(1); });
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!