We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
mocked
partial
When using the vi.mocked helper with the partial flag the type for mockResolvedValue is incorrect for async functions.
vi.mocked
mockResolvedValue
interface FooBar { foo: () => void; bar: () => boolean; } type FooBarAsyncFactory = () => Promise<FooBar>; const mockFactoryAsync: FooBarAsyncFactory = vi.fn(); vi.mocked(mockFactoryAsync, { partial: true }).mockResolvedValue({ foo: vi.fn(), // <- Throws Type error });
It currently expects: Partial<Promise<FooBar>> but should expect Promise<Partial<FooBar>>
Partial<Promise<FooBar>>
Promise<Partial<FooBar>>
An example can be viewed here: StackBlitz
System: OS: macOS 13.3.1 CPU: (8) arm64 Apple M1 Pro Memory: 1.22 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.0 - ~/.local/share/rtx/installs/node/18.16.0/bin/node npm: 9.5.1 - ~/.local/share/rtx/installs/node/18.16.0/bin/npm Watchman: 2023.05.22.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 113.0.5672.126 Firefox: 110.0.1 Safari: 16.4 npmPackages: @vitest/browser: workspace:* => 0.31.1 @vitest/coverage-c8: workspace:* => 0.31.1 @vitest/coverage-istanbul: workspace:* => 0.31.1 @vitest/ui: workspace:* => 0.31.1 vite: ^4.2.1 => 4.2.1 vitest: workspace:* => 0.31.1
pnpm
The text was updated successfully, but these errors were encountered:
Start a new pull request in StackBlitz Codeflow.
Sorry, something went wrong.
PartialMock
Successfully merging a pull request may close this issue.
Describe the bug
When using the
vi.mocked
helper with thepartial
flag the type formockResolvedValue
is incorrect for async functions.It currently expects:
Partial<Promise<FooBar>>
but should expectPromise<Partial<FooBar>>
Reproduction
An example can be viewed here: StackBlitz
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: