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

307
Views
Broma: esperar que el objeto no tenga propiedad

Quiero escribir una prueba que afirme que un objeto dado no tiene ciertas propiedades.

Digamos que tengo una función

 function removeFooAndBar(input) { delete input.foo; delete input.bar; return input; }

Ahora quiero escribir una prueba:

 describe('removeFooAndBar', () => { it('removes properties `foo` and `bar`', () => { const data = { foo: 'Foo', bar: 'Bar', baz: 'Baz', }; expect(removeFooAndBar(data)) .toEqual(expect.objectContaining({ baz: 'Baz', // what's left foo: expect.not.exists() // pseudo bar: undefined // this doesn't work, and not what I want })); }); });

¿Cuál es la forma correcta de afirmar esto?

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

0

Solo intentaría:

 expect(removeFooAndBar(data)) .toEqual({ baz: 'Baz' })
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!