jest: [Bug]: `MockedClass` does not accept a class as a type parameter
Version
29.5.0
Steps to reproduce
import type { MockedClass } from "jest-mock";
class Extension {
public dependencies(): Array<Extension> {
return [];
}
}
type Test = MockedClass<Extension>;
Expected behavior
I would expect the Test
type to be usable for e.g. automocking ES6 classes
Actual behavior
I get the following error:
2344: Type 'Extension' does not satisfy the constraint 'ClassLike'. Type 'Extension' provides no match for the signature 'new (...args: any): any'.
Additional context
No response
Environment
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Binaries:
Node: 20.2.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.6.7 - /usr/bin/npm
npmPackages:
jest: ^29.5.0 => 29.5.0
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (7 by maintainers)
Ah… Right. I was adding
jest.mock("./Extension");
, because you are extendingExtension
so it has to be mocked somehow.