# Using wasm modult 'ic-vetkd-utils' in Jest

**URL:** <https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312>\
**Category:** Developers\
**Created:** [September 25, 2023, 6:50pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312 "2023-09-25T18:50:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_d](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@p\_d](https://forum.dfinity.org/u/p_d)\
**Post date:** [September 25, 2023, 6:50pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/1 "2023-09-25T18:50:36Z")

</div>

We are using the `ic-vetkd-utils` WASM module successfully in our frontend to benefit from an easy access to the latest VetKD features provided by dfinity (find it here: [https://github.com/dfinity/examples/tree/master/rust/vetkd](https://github.com/dfinity/examples/tree/master/rust/vetkd))

```auto
import * as vetkd from 'ic-vetkd-utils';
const seed = window.crypto.getRandomValues(new Uint8Array(32));
const tsk = new vetkd.TransportSecretKey(seed);

```

However, for e2e integration tests we are using **Jest** and we cannot import the very same module with the same code as above, it simply results in `Cannot find module 'ic-vetkd-utils' from 'tests/my.test.js'`

Any ideas?

---

<div class="post-metadata">

**Author:** ![NathanosDev](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nathanosdev/32/7204_2.png) [@NathanosDev](https://forum.dfinity.org/u/NathanosDev)\
**Post date:** [September 25, 2023, 7:58pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/2 "2023-09-25T19:58:36Z")

</div>

It depends on how you’ve set your project up. How are you resolving the module for your frontend code and how is your Jest config setup?

---

<div class="post-metadata">

**Author:** ![p\_d](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@p\_d](https://forum.dfinity.org/u/p_d)\
**Post date:** [September 25, 2023, 8:23pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/3 "2023-09-25T20:23:51Z")

</div>

The module is stored in the root directory as `ic-vetkd-utils-0.1.0.tgz` and referenced in package.json:

```auto
"ic-vetkd-utils": "file:ic-vetkd-utils-0.1.0.tgz",

```

That works fine for the frontend code, I can import and use the module as described in the code above.

So far I started on a green field with Jest, having simply this file:

```auto
import * as vetkd from 'ic-vetkd-utils';

describe("My Tests", () => {
    test("it should use vetkd", async () => {
        //const seed = crypto.randomBytes(32);
        //const tsk = new vetkd.TransportSecretKey(seed);
    }, 10000); // Set timeout to 10s
});

```

No Jest config yet, and simply this import fails with `Cannot find module 'ic-vetkd-utils' from 'tests/my.test.js'`…

---

<div class="post-metadata">

**Author:** ![NathanosDev](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nathanosdev/32/7204_2.png) [@NathanosDev](https://forum.dfinity.org/u/NathanosDev)\
**Post date:** [September 25, 2023, 8:26pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/4 "2023-09-25T20:26:49Z")

</div>

I think you need the `moduleNameMapper` config option from Jest: [Configuring Jest · Jest](https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring)  
There you can map `ic-vetkd-utils` to `<rootDir>/ic-vetkd-utils-0.1.0.tgz`.

---

<div class="post-metadata">

**Author:** ![p\_d](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@p\_d](https://forum.dfinity.org/u/p_d)\
**Post date:** [September 26, 2023, 5:09am UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/5 "2023-09-26T05:09:23Z")

</div>

Thanks, will try out tonight…

By the way, `ic-vetkd-utils` seems to be a normal module available in `node_modules`:  
 ![Screenshot 2023-09-26 at 07.08.23](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/d/d85c9a605292f3cd3003ebcb88030fd6206ca821.png)

---

<div class="post-metadata">

**Author:** ![p\_d](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@p\_d](https://forum.dfinity.org/u/p_d)\
**Post date:** [September 26, 2023, 6:56pm UTC](https://forum.dfinity.org/t/using-wasm-modult-ic-vetkd-utils-in-jest/23312/6 "2023-09-26T18:56:37Z")

</div>

No luck so far with the moduleNameMapper, need to investigate further…
