-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
useObserver
registry refactor
#3598
Conversation
🦋 Changeset detectedLatest commit: b6e7128 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks for putting that in a separate PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
less code = It's better :D
throw new Error("This test must run with node >= 14") | ||
} | ||
|
||
expect(observerFinalizationRegistry).toBeInstanceOf(globalThis.FinalizationRegistry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it do if it fails? it's not inside any test
import { observerFinalizationRegistry } from "../src/utils/observerFinalizationRegistry" | ||
import { TimerBasedFinalizationRegistry } from "../src/utils/UniversalFinalizationRegistry" | ||
|
||
expect(observerFinalizationRegistry).toBeInstanceOf(TimerBasedFinalizationRegistry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it do if it fails?
Throws?
it's not inside any test
Does it matter?
It's mainly intented to assert environment (bug in the test), rather than testing that observerFinalizationRegistry
resolves to correct type (bug in the actual tested code).
Arguably I could split these into two, assertion to check globalThis
for (not) being FinalizationRegistry
and then an actual test
for observerFinalizationRegistry
. However I don't see much value in doing so.
import gc from "expose-gc/function" | ||
import { observerFinalizationRegistry } from "../src/utils/observerFinalizationRegistry" | ||
|
||
if (typeof globalThis.FinalizationRegistry !== "function") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this assertion also to expect to match the other checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... But then the error message won't be the same think think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did want to preserve the message.
As discussed here #3590 (comment)