jest-chain
                                
                                 jest-chain copied to clipboard
                                
                                    jest-chain copied to clipboard
                            
                            
                            
                        Support promises and returning matcher from test
What
Feature: support async returns from matchers
Why
If you want to use jest-chain and you also need to return a Promise from your test function.  Without this change, jest-chain will throw away all the promises.
Notes
This makes jest-chain always return a promise.  The promise also has all the matchers available on it.  If a matcher in the chain returns a promise, the promise returned by chained matchers will depend on that promise.
Housekeeping
- [x] Unit tests
- [x] Documentation is up to date
- [x] No additional lint warnings
Codecov Report
Merging #11 into master will not change coverage. The diff coverage is
100.00%.
@@            Coverage Diff            @@
##            master       #11   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           23        24    +1     
  Branches         3         4    +1     
=========================================
+ Hits            23        24    +1     
| Impacted Files | Coverage Ξ | |
|---|---|---|
| src/chain.js | 100.00% <100.00%> (ΓΈ) | 
Continue to review full report at Codecov.
Legend - Click here to learn more
Ξ = absolute <relative> (impact),ΓΈ = not affected,? = missing dataPowered by Codecov. Last update dde0129...6828dcc. Read the comment docs.
May supersede https://github.com/mattphillips/jest-chain/pull/9
Fixes https://github.com/mattphillips/jest-chain/issues/8
Fixes https://github.com/mattphillips/jest-chain/issues/1
@mattphillips I resolved the conflicts, in case you were waiting for that. Let me know if there's anything else I can do to move this one forwards.
ey, @mattphillips, is it going to be merged? :+1:
I've also updated the typing to reflect that rejects and resolves return a promise that also has matchers on it.
/cc @mattphillips
Would love to see this merged. Thank you @dobesv for your work on this.
@mattphillips is it possible to merge that priceless PR?
Sorry for the delay in coming to this! The promises issue has been fixed in: https://www.npmjs.com/package/jest-chain/v/1.1.6
As for returning chained matchers (synchronous ones) inside of a promise to allow returning expect I'm not too sure this is a good idea and if it will cause existing tests to break so have for now chosen not to support this as it deviates from Jests behaviour.
I've added a skipped test for this for future reference https://github.com/mattphillips/jest-chain/blob/da5a0e0e5d19668cf8b24a6e84168beba37855b0/src/index.test.js#L56