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

371
Views
@testing-library/vue :: las pruebas emiten un evento en el componente VueJS usando debounce

Estoy tratando de probar un evento emitido por un campo de entrada, que tiene un método de actualización de rebote.

Sin rebote, pasó la prueba, sin problemas.

Aquí hay una parte del código.

 import { render } from '@testing-library/vue'; import userEvent from '@testing-library/user-event'; import debounce from 'lodash.debounce'; const template = { template: '<input v-model="searchText" @input="update" type="search" />', data() { return { searchText: '', }; }, methods: { update: debounce(function (e) { this.searchText = e.target.value; if (this.searchText.length >= 3) this.$emit('update-items', this.searchText); }, 300), }, }; it('should emit [update-items] event if the query length typed on search input field is equal os greater than three', async () => { // * Arrange // * Act const { container, emitted } = await render(template); const el = container.querySelector('input'); await userEvent.type(el, 'abcd'); // * Assert expect(emitted()).toHaveProperty('update-items'); // ! FAIL });

El original está aquí: https://gist.github.com/vicainelli/cf614ef7d7967684ebab6cae8290033e

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Me di cuenta, solo tenía que burlarme de la dependencia de lodash.debounce

 jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
about 4 years ago · Juan Pablo Isaza Report
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!