Skip to content

test: let the mock hold the world, instead of building it here - #25

Merged
fcsouza merged 1 commit into
masterfrom
test/mock-world-collections
Sep 14, 2026
Merged

fcsouza merged 1 commit into
masterfrom
test/mock-world-collections

Conversation

@fcsouza

@fcsouza fcsouza commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Two test files stubbed game.items by hand, because the mock's was an empty array and the code under test walks the collection. tests/export.test.ts also stubbed game.journal down to a single find.

@vttforge/testing 0.14.0 makes those real collections and takes the documents as options, so both stubs are gone:

restore = withMockFoundry({ user: { isGM }, items: items() }).restore;

asUser in the API test drops from nine lines to two. Same fixtures, same 31 tests.

This is the third round of the same loop: the module needed something, the mock did not have it, the SDK grew it, and the module deleted the workaround. The stubs it deletes here are the ones written two PRs ago when the code started walking game.items instead of filtering it.

pnpm run typecheck is clean and the 31 unit tests pass.

Two test files stubbed `game.items` by hand, because the mock's was an empty
array and the code under test walks the collection. One of them also stubbed
`game.journal` down to a single `find`.

`@vttforge/testing` 0.14.0 makes those real collections and takes the documents
as options, so both stubs are gone and the fixtures are passed straight in.
`asUser` in the API test drops from nine lines to two.

Same fixtures, same 31 tests.
@fcsouza
fcsouza merged commit 0f764ea into master Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant