Closed ljrahn closed 1 year ago
Hi @ljrahn,
Sorry, I missed the notification for this issue. Did you get it sorted in the end?
Setting up the test environment is not really in our scope so I would suggest seeking help from the jest/jsdom folks instead.
Hello team. I am facing 2 issues, and maybe they should be created in separate issues, but I will see if this is okay. I am encountering issues when trying to use jsdom environment in jest. I reproduce the issues in the following repo and briefly explain the issues in the README: https://github.com/ljrahn/test-hooks.
Issue 1 - fetch is not defined:
it seems that when using jsdom environment, fetch is not defined and we need to install a separate fetch dependency then set in the globals. I would expect that jsdom would already have fetch defined no? The README explains how to workaround the issue.
Issue 2 - issues transpiling some dependencies when using jsdom environment but does not occur when using node environment.
I can reproduce the issue with firebase-admin (in my actual full project i use firebase admin in my tests to clean them up so its kind of a necessity). i end up hitting this error when trying to import:
we can fix this issue by changing the testEnvironment to "node" in jest.config.js, but obviously our hook wont work then because it requires some sort of dom environment in order to create elements.
any help would be greatly appreciated! thank you