There is a bug with @hadronous/pic

  1. I tried await PocketIc.create() but I got error TypeError: Cannot read properties of undefined (reading 'protocol')
  2. I tried await PocketIc.create(url)* where url is http://localhost:8080 that i got from dfx start --clean but I also got another error SyntaxError: Unexpected token 'C', "Could not "... is not valid JSON
  3. I tried dfx deploy backend to make sure the test runes on backend canister
const setupTestEnvironment = async () => {
  const url: URL = import.meta.env.VITE_IC_HOST;
  console.log({ url_is_here: url });
  const alice = createIdentity("1");
  const pic = **await PocketIc.create(url)**;
}

The nice thing about picture pic.js is that you don’t have to run DFX Or PocketIC. The package will set up the server for you and collect the URL. You may want to check out one of the guides for how to get set up. I use and use this.

Most of the magic is in the global set up and global teardown files.

![Screenshot 2024-11-22 at 11.47.07 AM|690x333](upload://eVOc1ioMZi6FooyLmcS5O84ZK5b.png)

const alice = createIdentity("1");
  const picIcServer = await PocketIcServer.start();


  const url = picIcServer.getUrl();
  const pic = await PocketIc.create(url);

  process.env.PIC_URL = url;
  global.__PIC__ = picIcServer;

  const fixture = await pic.setupCanister<_SERVICE>(
    idlFactory,
    WASM_PATH,
  );

Odd…what version of dfx did you use to compile the wasm?

I am using dfx 0.24.0 and

rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.82.0 (f6e511eec 2024-10-15)`