Canister declarations
PicJS creates actors from a canister’s Candid interface: an idlFactory that encodes and decodes calls, and a _SERVICE type that describes them. Generate both from the canister’s .did file with @icp-sdk/bindgen:
npx @icp-sdk/bindgen --did-file ./counter.did --out-dir ./tests --actor-disabledThis writes tests/declarations/counter.did.js and tests/declarations/counter.did.d.ts. --actor-disabled skips the actor wrapper, which PicJS doesn’t need.
The declarations export everything PicJS needs, for example in tests/src/counter.spec.ts:
import { IDL } from '@icp-sdk/core/candid';import { _SERVICE, idlFactory, init } from '../declarations/counter.did';
const fixture = await pic.setupCanister<_SERVICE>({ idlFactory, wasm: WASM_PATH, arg: IDL.encode(init({ IDL }), [countInitArg]),});init describes the canister’s init arguments, so arg can be encoded with the same types the canister expects.