@@ -1461,15 +1461,14 @@ expectPrototype._createWrappedExpect = function (
14611461 for ( let i = 2 ; i < arguments . length ; i += 1 ) {
14621462 args [ i - 2 ] = arguments [ i ] ;
14631463 }
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+ )
14731472 ) ;
14741473 }
14751474
@@ -1573,20 +1572,39 @@ expectPrototype._executeExpect = function (
15731572 ) ;
15741573
15751574 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+ ] ) ;
15841580 }
15851581
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+ ) ;
15901608} ;
15911609
15921610expectPrototype . _camelCaser = function ( context , subjectType , subject ) {
@@ -1644,34 +1662,13 @@ expectPrototype._expect = function (context, args, forwardedFlags) {
16441662 }
16451663
16461664 try {
1647- let { result , wrappedExpect } = this . _executeExpect (
1665+ return this . _executeExpect (
16481666 context ,
16491667 subject ,
16501668 testDescriptionString ,
16511669 Array . prototype . slice . call ( args , 2 ) ,
16521670 forwardedFlags
16531671 ) ;
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- ) ;
16751672 } catch ( e ) {
16761673 if ( e && e . _isUnexpected ) {
16771674 let newError = e ;
@@ -1951,8 +1948,6 @@ expectPrototype._callInNestedContext = function (callback) {
19511948} ;
19521949
19531950expectPrototype . shifty = function ( subject , args , rest , legacyMode ) {
1954- this . _assertWrappedExpect ( ) ;
1955-
19561951 const nextArgumentType = this . findTypeOf ( rest [ 0 ] ) ;
19571952 if ( legacyMode ) {
19581953 // Legacy
@@ -1991,7 +1986,7 @@ expectPrototype.shifty = function (subject, args, rest, legacyMode) {
19911986 }
19921987 ) ;
19931988 } else if ( nextArgumentType . is ( 'string' ) ) {
1994- return this . execute ( subject , ...rest ) ;
1989+ return this ( subject , ...rest ) ;
19951990 } else {
19961991 return subject ;
19971992 }
0 commit comments