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

173
Views
How do I check if file upload time recorded on UI is correct in cypress

I am writing cypress test case in which I have to upload a file. Once upload completes, the UI refreshes to show the upload time. I have to assert that the file upload time recorded is indeed correct. So I captured the date time displayed. It was Oct. 5, 2021, 3:29 a.m.. Also once upload completes I can get the current time in the test case with say new Date(). My doubt is how do I compare these two?

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

0

The date-time captured from the UI is a string, so you need to parse it to a date for comparison.

For example, using dayjs

Since the string is a slightly non-standard format, you can supply a format string for parsing.

The only thing that needs extra work is removing the dots in a.m.

const dateString = 'Oct. 5, 2021, 12:31 a.m.'
  .replace('a.m.', 'am')
  .replace('p.m.', 'pm')

const uploadDate = dayjs(dateString, 'MMM. DD, YYYY, HH:MM a')  // parse

const now = dayjs()
expect(uploadDate.isSame(now, 'minute')).to.eq(true) // uploaded in last minute

// or

const diffMinutes = now.minute() - uploadDate.minute()
expect(diffMinutes).to.be.lte(1)  
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!