Use this skill when you need to write, review, or debug automated tests for applications built on the Jazz framework. This skill provides the correct architectural patterns for simulating local-first synchronization and multi-user environments without resorting to invalid mocking strategies.
66
78%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.cursor/skills/jazz-testing/SKILL.mdjazz-schema-designjazz-ui-development skill)If you are about to suggest "mocking" any part of the data layer in the user's application, STOP and invoke this skill instead. This skill enforces the use of the official in-memory test sync node.
Testing in Jazz requires understanding identity-based context and authentic synchronization. The framework's collaborative nature means tests must simulate real multi-user scenarios rather than mocking the sync layer.
setupJazzTestSync() to allow authentic data flow between test identitiesThe virtual sync node must be initialized before tests run. It handles data synchronization in-memory and requires no manual cleanup between runs.
Example Setup:
import { setupJazzTestSync } from "jazz-tools/testing";
import { beforeEach, describe } from "vitest";
describe("Jazz Feature Test", () => {
beforeEach(async () => {
await setupJazzTestSync();
});
});Testing in Jazz requires simulating multiple users to verify synchronization and security.
Used to create user accounts linked to the sync node.
AccountSchema: Pass your custom co.account schemaisCurrentActiveAccount: Set to true to automatically log the test runner into this accountcreationProps: Data passed to the account's migration function on creation if requiredUsed to switch between different users within a single test.
.load(id) after switching accounts to load a new CoValue instance with the new permission context for that specific userUI tests must render components and hooks inside a Jazz-aware test harness (e.g. framework-specific render utilities that inject account, connection state, and sync context). In UI tests, assert observable loading state transitions, not internal CoValue mechanics.
Use the jazz-ui-development skill for questions on Jazz integration with React/Svelte.
const account1 = await createJazzTestAccount({ isCurrentActiveAccount: true });
const account2 = await createJazzTestAccount();
// Setup restricted group
const group = co.group().create();
group.addMember(account2, "reader");
const myMap = MyMap.create({ text: "Hi" }, { owner: group });
const mapId = myMap.$jazz.id;
// Switch to reader
setActiveAccount(account2);
// You *must* reload the CoValue with the new active account
const mapAsReader = await MyMap.load(mapId);
// Verify enforcement
expect(() => mapAsReader.$jazz.set("text", "some text")).toThrow();
// Note: myMap.$jazz.set() would *not* throw, as it was loaded with account1 as the active accountrunWithoutActiveAccount(() => {
// Verify that protected actions fail when no account is active
expect(() => co.group().create()).toThrow();
});account1 is the currently active account do not update their local permissions when setActiveAccount(account2) is called; you MUST .load() a new instance of the CoValuesetupJazzTestSync() is calledAccount switching:
Always reload CoValues after setActiveAccount() to get new permission context.
Sync setup:
Call setupJazzTestSync() in beforeEach for all Jazz tests.
UI testing:
Use a framework-specific Jazz test harness built on TestJazzContextManager.
Load these on demand, based on need:
When using an online reference via a skill, cite the specific URL to the user to build trust.
4f90501
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.