@@ -1461,15 +1461,14 @@ expectPrototype._createWrappedExpect = function (
1461
1461
for ( let i = 2 ; i < arguments . length ; i += 1 ) {
1462
1462
args [ i - 2 ] = arguments [ i ] ;
1463
1463
}
1464
- return wrappedExpect . _callInNestedContext (
1465
- ( ) =>
1466
- parentExpect . _executeExpect (
1467
- context . child ( ) ,
1468
- subject ,
1469
- testDescriptionString ,
1470
- args ,
1471
- wrappedExpect . flags
1472
- ) . result
1464
+ return wrappedExpect . _callInNestedContext ( ( ) =>
1465
+ parentExpect . _executeExpect (
1466
+ context . child ( ) ,
1467
+ subject ,
1468
+ testDescriptionString ,
1469
+ args ,
1470
+ wrappedExpect . flags
1471
+ )
1473
1472
) ;
1474
1473
}
1475
1474
@@ -1573,20 +1572,39 @@ expectPrototype._executeExpect = function (
1573
1572
) ;
1574
1573
1575
1574
if ( assertionRule . expect && assertionRule . expect !== this . _topLevelExpect ) {
1576
- return {
1577
- result : assertionRule . expect . _expect ( context , [
1578
- subject ,
1579
- testDescriptionString ,
1580
- ...args ,
1581
- ] ) ,
1582
- wrappedExpect,
1583
- } ;
1575
+ return assertionRule . expect . _expect ( context , [
1576
+ subject ,
1577
+ testDescriptionString ,
1578
+ ...args ,
1579
+ ] ) ;
1584
1580
}
1585
1581
1586
- return {
1587
- result : oathbreaker ( assertionRule . handler ( wrappedExpect , subject , ...args ) ) ,
1588
- wrappedExpect,
1589
- } ;
1582
+ let result = oathbreaker (
1583
+ assertionRule . handler ( wrappedExpect , subject , ...args )
1584
+ ) ;
1585
+
1586
+ if ( utils . isPromise ( result ) ) {
1587
+ result = wrapPromiseIfNecessary ( result ) ;
1588
+ if ( result . isPending ( ) ) {
1589
+ result = result . then ( undefined , ( e ) => {
1590
+ if ( e && e . _isUnexpected && context . level === 0 ) {
1591
+ this . setErrorMessage ( e ) ;
1592
+ }
1593
+ throw e ;
1594
+ } ) ;
1595
+ this . notifyPendingPromise ( result ) ;
1596
+ }
1597
+ } else {
1598
+ result = makePromise . resolve ( result ) ;
1599
+ }
1600
+ // Her mangler vi wrappedExpect?
1601
+ return wrappedExpect . addAdditionalPromiseMethods (
1602
+ result ,
1603
+ this ,
1604
+ subject ,
1605
+ Array . prototype . slice . call ( args , 0 , 2 ) ,
1606
+ wrappedExpect
1607
+ ) ;
1590
1608
} ;
1591
1609
1592
1610
expectPrototype . _camelCaser = function ( context , subjectType , subject ) {
@@ -1644,34 +1662,13 @@ expectPrototype._expect = function (context, args, forwardedFlags) {
1644
1662
}
1645
1663
1646
1664
try {
1647
- let { result , wrappedExpect } = this . _executeExpect (
1665
+ return this . _executeExpect (
1648
1666
context ,
1649
1667
subject ,
1650
1668
testDescriptionString ,
1651
1669
Array . prototype . slice . call ( args , 2 ) ,
1652
1670
forwardedFlags
1653
1671
) ;
1654
- if ( utils . isPromise ( result ) ) {
1655
- result = wrapPromiseIfNecessary ( result ) ;
1656
- if ( result . isPending ( ) ) {
1657
- result = result . then ( undefined , ( e ) => {
1658
- if ( e && e . _isUnexpected && context . level === 0 ) {
1659
- this . setErrorMessage ( e ) ;
1660
- }
1661
- throw e ;
1662
- } ) ;
1663
- this . notifyPendingPromise ( result ) ;
1664
- }
1665
- } else {
1666
- result = makePromise . resolve ( result ) ;
1667
- }
1668
- return wrappedExpect . addAdditionalPromiseMethods (
1669
- result ,
1670
- this ,
1671
- subject ,
1672
- Array . prototype . slice . call ( args , 0 , 2 ) ,
1673
- wrappedExpect
1674
- ) ;
1675
1672
} catch ( e ) {
1676
1673
if ( e && e . _isUnexpected ) {
1677
1674
let newError = e ;
@@ -1951,8 +1948,6 @@ expectPrototype._callInNestedContext = function (callback) {
1951
1948
} ;
1952
1949
1953
1950
expectPrototype . shifty = function ( subject , args , rest , legacyMode ) {
1954
- this . _assertWrappedExpect ( ) ;
1955
-
1956
1951
const nextArgumentType = this . findTypeOf ( rest [ 0 ] ) ;
1957
1952
if ( legacyMode ) {
1958
1953
// Legacy
@@ -1991,7 +1986,7 @@ expectPrototype.shifty = function (subject, args, rest, legacyMode) {
1991
1986
}
1992
1987
) ;
1993
1988
} else if ( nextArgumentType . is ( 'string' ) ) {
1994
- return this . execute ( subject , ...rest ) ;
1989
+ return this ( subject , ...rest ) ;
1995
1990
} else {
1996
1991
return subject ;
1997
1992
}
0 commit comments