How can I mock a module that only provides type definitions? #7228
-
Hi, I'm trying to write unit tests for a library that uses skyrim-platform. This package is rather peculiar in that it only provides a type definition file and has an empty entry point (i.e., the Understandably, unit tests fail with the following error:
However, if I try to mock it using
Is there any way I can mock such a package so that I can unit-test it using Vitest? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is just how Vite works. To make Vite aware of this module and not fail during transformation, define an alias. More in docs: https://vitest.dev/guide/mocking.html#virtual-modules |
Beta Was this translation helpful? Give feedback.
This is just how Vite works. To make Vite aware of this module and not fail during transformation, define an alias. More in docs: https://vitest.dev/guide/mocking.html#virtual-modules