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

640
Vistas
How to test file upload and file content in TypeScript Unit Test

I am trying to test an input tag but I want to test the content of the uploaded file. here is the code -

<input
  data-testid="file-input"
  type="file"
  accept=".csv, .tsv"
  onChange={(event) => {
    if (event.target.files !== null) {
      setCsvFile(event.target.files[0]);
      let reader = new FileReader();
      var content: string | ArrayBuffer | null | undefined;

      reader.onload = function () {
        content = reader.result;
        console.log(reader.result);
      };

      reader.onerror = function () {
        console.log(reader.error);
      };

      reader.readAsText(event.target.files[0]);
    }
  }}
/>;

How can I unit test what is being read by FileReader on file upload?

about 4 years ago · Juan Pablo Isaza
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