Loading...
Loading...
Step-by-step guide for writing focused, practical tests for Dust codebases following the 80/20 principle.
npx skill4agent add dust-tt/dust dust-testfront/tests/utils/factoriesfront/tests/utils/utilsimport {describe, it, expect} from "vitest";
import {makeTestWorkspace, makeTestUser} from "tests/utils/factories";
describe ("ComponentName or FunctionName", () => {
it ("should handle the main happy path", async () => {
// Arrange: Set up using factories
const {workspace} = createResourceTest ()
// Act: Execute the code
const result = await functionUnderTest (workspace);
// Assert: Verify behavior
expect (result).toBeDefined ();
});
it ("should handle the most common edge case", async () => {
// Test the second most important scenario
});
});describe ("createConversation", () => {
it ("creates conversation with valid params", async () => {
const {workspace, user} = createResourceTest ()
const conversation = await createConversation ({
workspace,
userId: user.id,
title: "Test"
});
expect (conversation.sId).toBeDefined ();
expect (conversation.title).toBe ("Test");
});
it ("fails without required permissions", async () => {
const {workspace, user} = createResourceTest ()
await expect (
createConversation ({workspace, userId: user.id})
).rejects.toThrow ("Permission denied");
});
});file.test.tsnpm test