changesets: update @sucrase/plugin-jest changeset to include instructions for how to work around re-export issue

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-08 15:00:06 +02:00
parent 432af8743f
commit 69cf5b2549
+18
View File
@@ -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);
```