Closed Chris55 closed 1 year ago
Thanks @Chris55 !
Sadly, as ts-jest
(jest) is setup and bootstrapped before executing any tests, the provided configuration (for our case, specifically the options
property of the astTransformer) cannot be dynamic and computed on a "per test" basis. So, it is currently impossible to define the metaObjectReplacement
value dynamically from within the tests themselves. It is also indeed not possible to mock any imports that are used within the jest configuration module, which could have been kind of cool...
With that being said, I'm currently preparing a new minor version of the package, that will allow the metaObjectReplacement
property to be an object factory function (and for its sub-properties to be a factory function as well), to offer a little more flexibility and more dynamism for you to define more complex mocked values. Examples of that will be available in the README. as well as implemented in the project jest.config.ts
Hope that helps, don't be shy to give a little star to the repo 😃
Thanks for this nice transformer.
I'm wondering if you could share a simple test case where the metaObjectReplacement object is defined in a test, not in the config file.