diff --git a/.changeset/breezy-ways-try.md b/.changeset/breezy-ways-try.md index d8c22ed8ed..15e831a673 100644 --- a/.changeset/breezy-ways-try.md +++ b/.changeset/breezy-ways-try.md @@ -23,3 +23,21 @@ In order to switch back to `ts-jest`, install `ts-jest@^26.4.3` as a dependency ``` Note that this will override the default jest transforms included with the `@backstage/cli`. + +It is possible that some test code needs a small migration as a result of this change, which stems from a difference in how `sucrase` and `ts-jest` transform module re-exports. + +Consider the following code: + +```ts +import * as utils from './utils'; + +jest.spyOn(utils, 'myUtility').mockReturnValue(3); +``` + +If the `./utils` import for example refers to an index file that in turn re-exports from `./utils/myUtility`, you would have to change the code to the following to work around the fact that the exported object from `./utils` ends up not having configurable properties, thus breaking `jest.spyOn`. + +```ts +import * as utils from './utils/myUtility'; + +jest.spyOn(utils, 'myUtility').mockReturnValue(3); +```