Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

635
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda