Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Reader #1413

Open
mirinio opened this issue Apr 22, 2024 · 0 comments
Open

File Reader #1413

mirinio opened this issue Apr 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mirinio
Copy link

mirinio commented Apr 22, 2024

Describe the bug
I am running into issues with FileReader when running my jest tests.
This happens when I reference happy-dom jest-environment.
testEnvironment: '@happy-dom/jest-environment',

I get following error running a test for a pure function:

reader.readAsDataURL is not a function
TypeError: reader.readAsDataURL is not a function

the funcrion I am testing:

export function convertBlobToBase64(blob: Blob): Observable<string> {
    const reader = new FileReader();
>  reader.readAsDataURL(blob);
    return fromEvent(reader, 'load').pipe(map(() => (reader.result as string).split(',')[1]));
}

To Reproduce
Steps to reproduce the behavior:

  1. Reference testEnvironment: '@happy-dom/jest-environment' in your test setup.
  2. Write a jest test including FileReader.
  3. Run the reader.readAsDataURL(..) function
  4. See error

Expected behavior
FileReader should have a readAsDataURL function.

Screenshots
If applicable, add screenshots to help explain your problem.

Device:

  • OS: Windows
  • Browser Chrome

Additional context
I am working with an Angular project writing jest tests for util functions.

@mirinio mirinio added the bug Something isn't working label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant