Repository navigation
test: avoid the jsdom realm in the native asset button test - #555
Merged
Merged
Conversation
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
create-stream-fields.test.tsxruns under@vitest-environment jsdom, and the "Use XLM" test asserted againstnativeAssetContractId(), which callsAsset.native().contractId(...). That call throws inside jsdom because the SDK'sStrKey/sha256expects a NodeUint8Array, while jsdom'sUint8Arrayis a different constructor from a different realm —TypeError: expected Uint8Array, got type=object. The same call returnsCDLZFC3S…GCYSCin plain Node, so this is a test-environment realm mismatch, not a product bug.Closes #510
Change
components/create-stream-fields.test.tsx:vi.mock("@/lib/native-asset", ...)returns a fixed id for the assertion path. The test still assertsonFieldChangereceives whatevernativeAssetContractId()returns — the assertion is unchanged — but the return value is now computed outside jsdom, so the SDK call never happens here.CDLZFC3S…GCYSC), matching the value the issue reports for plain Node.Acceptance criteria
nativeAssetContractId).Notes on not weakening coverage
lib/native-asset.tsis unchanged, and its real behaviour is still covered bylib/native-asset.test.ts, which runs under Node (the project's defaulttest.environment— only files with@vitest-environment jsdomopt into jsdom). The mock is local to this test file.Testing
npm run check(lint, typecheck, test, build) — pass