-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Vitest 3] "Intl.Collator
is not a constructor" when using fake timers
#7142
Comments
Intl.Collator
is not a constructorIntl.Collator
is not a constructor when using async import()
in test
Intl.Collator
is not a constructor when using async import()
in testIntl.Collator
is not a constructor" when using async import()
in test
This looks like due to fake timers. Here is a simplified repro https://stackblitz.com/edit/vitest-dev-vitest-96ajsug5?file=test%2Fbasic.test.ts In v3, we changed the behavior of There's a PR #7097 but probably we haven't reviewed yet. In the mean time, you can explicitly set import { it, vi } from 'vitest';
it('repro', async () => {
console.log('[before]', Intl.Collator);
vi.useFakeTimers({
// or write this in `test.fakeTimers.toFake` config
toFake: [
'setTimeout',
'clearTimeout',
'setInterval',
'clearInterval',
'setImmediate',
'clearImmediate',
'Date',
],
});
console.log('[after]', Intl.Collator);
}); |
Intl.Collator
is not a constructor" when using async import()
in testIntl.Collator
is not a constructor" when using fake timers
Thanks! that did the trick. I updated the title for this issue accordingly. |
@spaceemotion feel free to try it out pre-release of the PR #7097 (comment) I confirmed the repro is fixed with this https://stackblitz.com/edit/vitest-dev-vitest-52wgjnc6?file=package.json |
Describe the bug
I am trying to upgrade to the latest Vitest 3 Beta. Our project does not use Vite for the build-pipeline (only a simple esbuild config, in fact), and we didn't need to do anything so far to get our tests running (we don't even have a vitest config).
However, after the upgrade, we suddenly see the following error in the console:
I thought it might have to do with the Vite 6 module resolution changes, but even tinkering with that one broke more than i liked. The project runs on Node v22, and Vitest v2 has worked without an issue so far.
The error also happens when I run vitest in isolation mode.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-ptkpew1o?file=test%2Fbasic.test.ts
Once the async import gets resolved, Vitest doesn't know what
Intl.
is.System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: