valid-expect-in-promise doesn't work with Promise.all
See original GitHub issueI have a test case that relies on multiple promises being tested with Promise.all
:
test('Resource loader: client usage', function () {
expect.assertions(2);
const quxLoader = ResourceLoader.create(['qux']);
let promiseResolve;
fetchResult = new Promise(resolve => promiseResolve = resolve);
const promise1 = quxLoader.load();
promise1.then(([x]) => expect(x.test).toBeTruthy());
const promise2 = quxLoader.load();
promise2.then(([x]) => expect(x.test).toBeTruthy());
promiseResolve({test: true});
return Promise.all([promise1, promise2]);
});
This causes the following eslint errors:
68:3 error Promise should be returned to test its fulfillment or rejection jest/valid-expect-in-promise
70:3 error Promise should be returned to test its fulfillment or rejection jest/valid-expect-in-promise
It’d be great if the rule would recognize Promise.all
and considered it valid.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Promise.all doesn't return none of it's promises if one of them fail
If one of the URL's is invalid, the Promise.all doesn't return any of the results; in other words, all responses must be valid...
Read more >Promise.allSettled() - JavaScript - MDN Web Docs
allSettled() method takes an iterable of promises as input and returns a single Promise . This returned promise fulfills when all of the...
Read more >Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >useEffect doesn't work as expected when Promise.all - Reddit
Because Promise.all does not sequentially call the functions your passing to it... they are already all fired. Promise.all just stops execution ...
Read more >Promise.all - Bluebird JS
The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array...
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 FreeTop 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
Top GitHub Comments
Yeah, that’s a bug 🙂 Doesn’t seem like the rule handles
Promise.all
at all. PR welcome! 😀🎉 This issue has been resolved in version 25.0.0-next.6 🎉
The release is available on:
Your semantic-release bot 📦🚀