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

303
Views
test input type file in jest

How i can simply make unit testing for the value of input type file :

<input required type="file" class="form-control blue-border" accept=".jpg, .jpeg, .png" data-testid="file" /> 

I tryed

descripe('ex....',()=>{
     test('ex.....',()=>{
     const file=screen.getByTestId('file')
     expect(file.value='myfile.png').toContain(/(\.jpg|\.jpeg|\.png)$/i)
})
})

but i have error : InvalidStateError: This input element accepts a filename, which may only be programmatically set to the empty string.

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

0

try this

expect(file.value).toMatch(/(\.jpg|\.jpeg|\.png)$/i)
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!