2.1.0 version with node and jest mocking causes errors
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
When upgrading to the newest versions of tslib, typescript, and jest I received the following error in an existing project:
TypeError: Cannot redefine property: upsertThing
at Function.defineProperty (<anonymous>)
jest.spyOn(transactionDomain, 'upsertThing');
upsertThing is a function exported from it's own file, then again exported from an index file via export *.... When jest tries to spy on it, this error is thrown with version 2.1.0 of tslib. But when I downgrade to tslib 1.14.1 the error goes away.
Version Info:
Node: Tried on both 12 and 14
jest: 26.6.3
ts-jest: 26.4.4
ts-node: 9.1.1
typescript: 4.1.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the error at jest.spyOn(transactionDomain, 'upsertThing') with tslib 2.1.0 and the listed TypeScript, Node, Jest, ts-jest, and ts-node versions. Trace the export from the standalone upsertThing file through the index export, then compare behavior with tslib 1.14.1. Done means identifying the compatibility regression and establishing a verified fix or clear reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100