import { Actor } from "@dfinity/agent";
import { Principal } from "@dfinity/principal";
import { TestContext } from "lightic";
const context = new TestContext();
let actor: Actor;
describe("Canister", () => {
beforeAll(async () => {
// @ts-ignore
const canister = await context.deploy('./.dfx/local/canisters/backend/backend.wasm');
console.log(canister)
const caller = Principal.anonymous();
// @ts-ignore
actor = Actor.createActor(canister.getIdlBuilder(), {
// @ts-ignore
agent: context.getAgent(caller),
canisterId: canister.get_id()
})
});
it("is true", () => {
console.log(actor);
expect(true).toBe(true);
});
});
Run it simply with:
npx jest
But I got this error:
FAIL tests/integration/canister.test.ts
Canister
✕ is true (1 ms)
● Canister › is true
TypeError: WebAssembly.Module.customSections(): Argument 0 must be a WebAssembly.Module
at WasmCanister.get_candid (node_modules/lightic/src/wasm_canister.ts:270:42)
at async WasmCanister.install_module_candid (node_modules/lightic/src/wasm_canister.ts:116:20)
at async ReplicaContext.install_canister (node_modules/lightic/src/replica_context.ts:198:5)
at async TestContext.deploy (node_modules/lightic/src/test_context.ts:49:20)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.083 s
The ./.dfx/local/canisters/backend/backend.wasm file exists.
(Note that I also had to use @ts-ignore, which I think is due to different versions of the @dfinity/* packages)
I'm trying to use LightIC with Jest.
I wrote this simple test:
Run it simply with:
But I got this error:
The
./.dfx/local/canisters/backend/backend.wasm
file exists.(Note that I also had to use
@ts-ignore
, which I think is due to different versions of the @dfinity/* packages)Context: