You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** @type {import('ts-jest').JestConfigWithTsJest} */module.exports={// [...]transform: {// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`'^.+\\.tsx?$': ['ts-jest',{jestGlobalsModuleName: 'my-jest-wrapper'// defaults to '@jest/globals'},],},}
Please consider supporting the option below to customize JEST_GLOBALS_MODULE_NAME.
Motivation
ts-jest will hoist statements like jest.mock.
import{jest}from'@jest/globals';import{app}from'./app';// ts-jest hoist `jest.mock` to the top of the filejest.mock('./app',()=>({app: 'foo'}));// so that `app` will be 'foo'console.log(app);
I have a wrapper which bundle the best pratices into one package. Just like the development experience of vitest:
import{jest,it,expect}from'my-test-framework';import{app}from'./app';// ts-jest will not hoist `jest.mock`jest.mock('./app',()=>({app: 'foo'}));it('test',()=>{expect(app).toBe('foo')// fail! because ts-jest won't hoist jest.mock})
npx my-test-framework
Supporting to customize JEST_GLOBALS_MODULE_NAME will help me.
Here is the example usage of vitest:
import{expect,test,vi}from'vitest'import{sum}from'./sum'vi.mock('./sum',()=>({default: {sum: (x,y)=>x+y}}));test('adds 1 + 2 to equal 3',()=>{expect(sum(1,2)).toBe(3)})
Example
No response
The text was updated successfully, but these errors were encountered:
🚀 Feature Proposal
Please consider supporting the option below to customize JEST_GLOBALS_MODULE_NAME.
Motivation
ts-jest
will hoist statements likejest.mock
.I have a wrapper which bundle the best pratices into one package. Just like the development experience of
vitest
:Supporting to customize JEST_GLOBALS_MODULE_NAME will help me.
Here is the example usage of
vitest
:Example
No response
The text was updated successfully, but these errors were encountered: