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

287
Views
Reaccionar biblioteca de prueba, mecanografiado, cargar archivo

Soy muy nuevo en escribir pruebas en reaccionar y tengo una entrada con el tipo de archivo. Quiero probarlo, pero cuando escribo la siguiente prueba:

 describe('Custom Drop Zone', () => { test('should upload the file', () => { const file = new File(['hello'], 'hello.png', { type: 'image/png' }) const { container } = render(<CustomDropZone />) const input = container.querySelector('#upload-file') }) })

Me sale el siguiente error:

 ● Custom Drop Zone › should upload the file ReferenceError: File is not defined 5 | describe('Custom Drop Zone', () => { 6 | test('should upload the file', () => { > 7 | const file = new File(['hello'], 'hello.png', { type: 'image/png' }) | ^ 8 | const { container } = render(<CustomDropZone />) 9 | 10 | const input = container.querySelector('#upload-file') at Object.<anonymous> (src/__tests__/home/CustomDropZone.test.tsx:7:18)

esta es la prueba que escribió la documentación oficial :

 test('upload file', () => { const file = new File(['hello'], 'hello.png', {type: 'image/png'}) render( <div> <label htmlFor="file-uploader">Upload file:</label> <input id="file-uploader" type="file" /> </div>, ) const input = screen.getByLabelText(/upload file/i) userEvent.upload(input, file) expect(input.files[0]).toStrictEqual(file) expect(input.files.item(0)).toStrictEqual(file) expect(input.files).toHaveLength(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!