Test your plugin
Start a real conciv engine with your plugin in a test, script the agent's replies, and drive the widget in a browser test.
This guide installs the test utilities, which the tutorial did not:
npm install -D vitest @conciv/backend-test-utils @internal/vitest-configpnpm add -D vitest @conciv/backend-test-utils @internal/vitest-configyarn add --dev vitest @conciv/backend-test-utils @internal/vitest-configbun add --dev vitest @conciv/backend-test-utils @internal/vitest-configTest your plugin the way the user uses it. A real engine loads your plugin, a scripted model plays the agent, and
your test checks what comes back. Nothing is mocked. This guide tests project_version from
Build your first plugin and release_ship from
Ask for permission. Both are direct tools, with codemode: false.
Copy this prompt into your agent. It builds this in your project from this page.
Build this in my project with conciv. conciv is a dev-only AI agent widget, and it already runs in my app. 1. Read https://conciv.dev/docs/plugins/guides/testing.md and follow it. It is the source of truth for the API. 2. If the project has the conciv-develop skill (conciv init installs it with the @conciv/skills docs pack), load it too. 3. Write a test for my plugin with @conciv/backend-test-utils: start a real engine with the plugin, and call its tool. 4. Install only the packages the page lists, with the package manager this project uses. 5. Run the test with `npx vitest run <the test file>` and show me the result. 6. When you are done, tell me what you changed and how to see it.
Call your tool in a test
Add the conciv test setup to a vitest config at your project root:
import {} from 'vitest/config'
import {} from '@internal/vitest-config/conciv-test'
export default ({
: [()], // <- each run gets its own conciv home, removed after
})Then call your tool on a real engine:
import {} from 'vitest'
import {} from '@conciv/backend-test-utils'
('the agent reads the project version', async ({
const = await
(await ..('project_version').
})Run it from your project root with npx vitest run.
A few things to notice:
- vitest collects tests from
test/unit,test/itandtest/e2e. Engine tests go intest/it. testis vitest'stestwith acreateEnginefixture. It starts the real engine on a free port.- The first argument of
createEngineis your conciv config. Here it is empty, becauseconciv/pluginsloads on its own, as in your app. directory: '.'resolves against vitest's working folder. Run vitest from your project root, or pass that folder.- The fixture stops every engine the test started when the test ends, pass or fail.
Script the agent
TestLLM plays the agent. Queue its replies, then send a message as the user:
import {} from 'vitest'
import {, } from '@conciv/backend-test-utils'
('shipping a branch asks the user first', async ({
const = await
await .(.
const = await .('permission.asked') // <- listen before it happens
const = ..
await (.)..
await ..()
await
})The turn runs your real tool, so the permission ask is real. engine.session.stop stops the turn, as the user's
Stop button does. TestLLM.text makes a plain text reply, to end a turn after a tool call.
Drive the widget in a browser test
A browser test renders the real widget against the real engine, in Chromium. Install what it imports, and the browser:
npm install -D @internal/frontend-test-utils @solidjs/testing-library @testing-library/user-eventpnpm add -D @internal/frontend-test-utils @solidjs/testing-library @testing-library/user-eventyarn add --dev @internal/frontend-test-utils @solidjs/testing-library @testing-library/user-eventbun add --dev @internal/frontend-test-utils @solidjs/testing-library @testing-library/user-eventnpx playwright install chromiumTurn on browser tests in the config with concivTest({browser: true}). Then check that the user sees the card:
import {} from 'vitest'
import {} from '@solidjs/testing-library'
import
import {, } from '@conciv/backend-test-utils'
import {} from '@internal/frontend-test-utils/app'
import from '../../conciv/plugins/project-version/plugin-experimental'
('the user sees the version card', async ({
const =
The test finds the composer by its label and types into it, as a user does. findByText waits until the card
shows.
Next steps
- Add a tool: the tools these tests call.
- Plugin API reference: every
ctxdomain.