Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda