Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Received 'Could not find a declaration file for module 'jest-extended/all' when importing jest-extended #577

Open
hollygcraig opened this issue Mar 8, 2023 · 0 comments

Comments

@hollygcraig
Copy link

Bug

I followed the (setup instructions)[https://jest-extended.jestcommunity.dev/docs/getting-started/setup] for using jest-extended with vitest. I had a typescript setup file, testSetup.ts, with:

import {expect} from "vitest";
import * as matchers from "jest-extended";
expect.extend(matchers);

and included the following in vite.config.ts

setupFiles: ["./testSetup.ts"]

However, I would receive the error 'Could not find a declaration for module 'jest-extended/all' when importing jest-extended in the testSetup.ts file.

Workaround
It appears that the root cause of this was that jest-extended does not provide type definitions for the module itself. A way around this, if you have a similar setup to me, is to replace the line in vite.config.ts where we have setupFiles: ["./testSetup"] with setupFiles: ["jest-extended/all"]. This works as the setup files is a javascript (rather than a typescript) file supplied by jest-extended, so we don't need type definitions for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant