# There is a bug with @hadronous/pic

**URL:** <https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602>\
**Category:** Developers\
**Created:** [November 21, 2024, 6:56am UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602 "2024-11-21T06:56:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [November 21, 2024, 6:56am UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602/1 "2024-11-21T06:56:43Z")

</div>

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

```ts
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)**;
}

```

 ![Screenshot 2024-11-21 at 2.56.26 PM](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/8/a/8afa65fe72e19ea59bb60cd9fc82287ec21fedb2.png)

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 21, 2024, 12:58pm UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602/2 "2024-11-21T12:58:56Z")

</div>

> **[Using Jest | PicJS](https://hadronous.github.io/pic-js/docs/guides/using-jest/)**
>
> Jest is a JavaScript testing framework that is widely used in the JavaScript community. It is recommended for beginners because it has the largest community and is the most widely used. Jest is also the officially supported test runner for PicJS.

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.

> **[Using Jest | PicJS](https://hadronous.github.io/pic-js/docs/guides/using-jest/)**
>
> Jest is a JavaScript testing framework that is widely used in the JavaScript community. It is recommended for beginners because it has the largest community and is the most widely used. Jest is also the officially supported test runner for PicJS.

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

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [November 22, 2024, 3:49am UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602/3 "2024-11-22T03:49:04Z")

</div>

> [@skilesare](#):
>
> [Using Jest | PicJS](https://hadronous.github.io/pic-js/docs/guides/using-jest/)

```ts
![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,
  );

```

 ![Screenshot 2024-11-22 at 11.47.07 AM](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/6/8/68a7588d9208fc2bbd2d8b002a22ea77b5558051.png)

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 22, 2024, 4:12pm UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602/4 "2024-11-22T16:12:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [November 23, 2024, 4:41am UTC](https://forum.dfinity.org/t/there-is-a-bug-with-hadronous-pic/37602/5 "2024-11-23T04:41:23Z")

</div>

I am using `dfx 0.24.0` and

```auto
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)`

```
