jest
jest copied to clipboard
fix(jest-runner): Handle unsafe worker_threads `structureClone` with `function` type in matchers
Summary
This PR solves this particular issue https://github.com/jestjs/jest/issues/14423
Test plan
Issue solved, now workerThreads can be used safely with function types
I tested the behaviour on examples/typescript suite. I added example test, changed config in package.json to use workers and reproduced the behaviour from the issue and the checked that it is fixed after my changes were implemented. Example test:
it('should not explode', () => {
const foo = () => {}
const bar = () => {}
expect(foo).toBe(bar)
})
Config:
// examples/typescript/package.json
"jest": {
"testEnvironment": "jsdom",
"workerThreads": true,
"maxWorkers": 1
}
Command:
yarn test --watch
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: dj-stormtrooper / name: Ilya Kuznetsov (e0f991a7244ecbd773cd7506beb24a7843d7b081, 76791cc71b1971f14faaf04f01bc29b8c1b308c6, 3a3295f67562b871b1ee5e0c1bae098644a417b1, a2a54a02285b625954e4d8ec1a231712cfaa47bc, ec421c8a58a9058162b55acb3d4ca18f45a7836a, 627031cefe29777db5f4d73660e7791b8db9a2b1, 9db8b2ef06b162699f61edcdc10358a139b2a052)
- :white_check_mark: login: SimenB / name: Simen Bekkhus (3f50677d9bcf18741aab0b42e33a615c8e02d481)
Deploy Preview for jestjs ready!
| Name | Link |
|---|---|
| Latest commit | 3f50677d9bcf18741aab0b42e33a615c8e02d481 |
| Latest deploy log | https://app.netlify.com/sites/jestjs/deploys/65e1ad90c7c04a00087b2df6 |
| Deploy Preview | https://deploy-preview-14436--jestjs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@SimenB I'm trying to solve the issue with unserialisable values with worker_threads, as discussed here, unfortunately I can't post comments to original PR since it's closed, so let's discuss here?
I made an implementation in this PR with the patch in jest-runner for workers exclusively but @mrazauskas pointed out that it's better to prepare it directly at circus/jasmine. While I'm completely fine with the approach I still have few topics to discuss:
- WDYT about this format, is it ok to replace undesired values with string placeholders?
- Maybe we could get some inspiration from
jest/pretty-formator reuse some code. - For what cases do we need an actual references to
expected/actualvalues? Wild idea, but can we keep only string representation of these objects (e.g. formatted withpretty-format)
@SimenB @mrazauskas Could you guys take a look here, please?
I'm ok to implement it in circus and jasmine, but I'm not sure if it's ok to replace any complex value with a string placeholder? (because of the type mismatch)
Good thing is that at least we keep the name of the original type, e.g. [Function foo] - it can be used by reporters
I'm ok to implement it in
circusandjasmine, but I'm not sure if it's ok to replace any complex value with a string placeholder? (because of the type mismatch)
I think that's fine - it should be stringified by the time a reporter gets the value. If people want to format the message themselves, that should be done in a custom matcher
What's the status of this PR? Do we still need this?
Closing due to inactivity. Happy to reopen (or please send a new PR) if anyone is still working on this.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.