You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
E2E tests have been broken since upgrading TypeScript from 4 to 5. The reason is that between TypeScript 5.2.2 and TypeScript 5.3.3, an internal property on sourceFiles, resolvedModules was removed, and moved to Program. See PR: microsoft/TypeScript#55790 This caused karma-typescript, which we use for the karma tests, to break as it was depending on that field to find modules and determine if it should bundle files. karma-typescript is deprecated and no longer maintained so we can't get a fix from it even though we know the problem.
In light of this, I'm migrating our E2E tests from karma to Jest.
Pros:
a lot of our users use Jest (in JSDOM mode) so this will catch SDK incompatibilities with it early
it's maintained
Cons:
Since Jest uses JSDOM and not a live headless browser, these tests don't catch any conflicts with real browser APIs
Also due to some things missing in JSDOM, we need to do some patches, polyfills, and mocks, and reduce some functionality
Details
Had to mock some browser APIs directly (service worker related) before calling getMessaging(), or else there would be an error
Had to turn off useFetchStreams on Firestore tests as JSDOM does not handle fetch readable streams well. There's no public API to turn it off in compat so I had to do it pretty hacky.
We had some special 5000ms timeouts on some tests because karma's default was 2000ms which wasn't enough. Jest's default is already 5000 so I got rid of the special settings on those tests.
Jest running in Node allows it to easily read process.env.APP_CHECK_DEFAULT_TOKEN in the config so we don't have to do the convoluted custom context.html that karma required
Did not touch the webpack build tests, those are still valuable as is, and still working (they test if the project builds in webpack without error)
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Have you guys considered vitest https://github.com/vitest-dev/vitest?
it is fast and well maintained, where jest is not seeing much activity lately.
It even has a browser mode where unit tests run in real browser.
Just wanted to mention this, as a long time user of firebase software
Have you guys considered vitest https://github.com/vitest-dev/vitest? it is fast and well maintained, where jest is not seeing much activity lately. It even has a browser mode where unit tests run in real browser. Just wanted to mention this, as a long time user of firebase software
Thanks! Yes, I considered vitest. We might migrate to it eventually if it becomes more popular, which it seems to be on its way to becoming. I went with Jest because it's currently the most commonly used, users often report issues with it, and so catching errors in it will impact the most users. If vitest grows in popularity I would love to move over, especially for real browser testing. We could also maybe do both, will put it in our wishlist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
E2E tests have been broken since upgrading TypeScript from 4 to 5. The reason is that between TypeScript 5.2.2 and TypeScript 5.3.3, an internal property on sourceFiles,
resolvedModuleswas removed, and moved toProgram. See PR: microsoft/TypeScript#55790 This causedkarma-typescript, which we use for the karma tests, to break as it was depending on that field to find modules and determine if it should bundle files.karma-typescriptis deprecated and no longer maintained so we can't get a fix from it even though we know the problem.In light of this, I'm migrating our E2E tests from karma to Jest.
Pros:
Cons:
Details
useFetchStreamson Firestore tests as JSDOM does not handle fetch readable streams well. There's no public API to turn it off in compat so I had to do it pretty hacky.