bun
bun copied to clipboard
ReferenceError: Can't find variable: jest
What version of Bun is running?
1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
Try to run any jest test without using @jest/globals
What is the expected behavior?
it should work
What do you see instead?
ReferenceError: Can't find variable: jest
Additional information
try to test against jest-fetch-mock
For run tests use command: bun test
I'm running using bun test path/to/myjesttest.ts
I don't think it's expected to polyfill/shim references to jest itself, only the functions expect, test, describe, etc.
do you have a file that reproduces this? I'm happy to investigate this if it is still impacting you
It affects eg. any test that uses jest-mock-extended
https://github.com/marchaos/jest-mock-extended/pull/119#issuecomment-1887493808
Having the same issue when running with bun test path/to/myjesttest.ts
bun --version
1.1.9
Having the same issue
# Unhandled error between tests
-------------------------------
77 | }
78 | }
79 |
80 | const isFn = unknown => typeof unknown === 'function'
81 |
82 | const isMocking = jest.fn(staticMatches(true))
^
ReferenceError: Can't find variable: jest
at ./project/node_modules/jest-fetch-mock/src/index.js:82:19
Bun version 1.1.21
I had the same issue, I fixed it by
- Installing
@types/bun - Importing the test utils from bun:
import { describe, test, expect } from "bun:test";