Jest 28 failure: should return an object or a Promise resolving to an object
See original GitHub issueThe following error is being thrown on Jest 28.1.0 due to Jest breaking changes. https://jestjs.io/docs/upgrading-to-jest28#transformer explains the necessary fix.
`process()` or/and `processAsync()` method of code transformer found at
"node_modules/jest-transform-graphql/index.js"
should return an object or a Promise resolving to an object. The object
must have `code` property with a string of processed code.
This error may be caused by a breaking change in Jest 28:
https://jestjs.io/docs/upgrading-to-jest28#transformer
Code Transformation Documentation:
https://jestjs.io/docs/code-transformation
Issue Analytics
- State:
- Created a year ago
- Reactions:22
- Comments:10
Top Results From Across the Web
Invalid return value: `process()` or/and ` ...
After updating from jest 27 to jest 28.1.0 all tests fail with the following exception: ... should return an object or a Promise...
Read more >Jest test fails when trying to test an asynchronous function ...
Be aware that an async function always returns a value (a Promise object), so the "usual" expect(() => yourThing()).toThrow() will not work.
Read more >Testing Asynchronous Code
Return a promise from your test, and Jest will wait for that promise to resolve. If the promise is rejected, the test will...
Read more >Node.js v19.3.0 Documentation
For example, assert.deepEqual() will behave like assert.deepStrictEqual() . In strict assertion mode, error messages for objects display a diff. In legacy ...
Read more >Promise.all() - JavaScript - MDN Web Docs
Return value · Already fulfilled, if the iterable passed is empty. · Asynchronously fulfilled, when all the promises in the given iterable fulfill ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@graphql-tools/jest-transform isn’t quite compatible, and doesn’t allow multiple operations per file.
I was trying to use
@graphql-tools/jest-transformbut it’s throwing an error when file has multiple operations.