@@ -467,7 +467,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
467467 const actual = this . _obj as any
468468 const [ propertyName , expected ] = args
469469 const getValue = ( ) => {
470- const hasOwn = Object . prototype . hasOwnProperty . call (
470+ const hasOwn = Object . hasOwn (
471471 actual ,
472472 propertyName ,
473473 )
@@ -660,7 +660,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
660660 function ( ...args : any [ ] ) {
661661 const spy = getSpy ( this )
662662 const spyName = spy . getMockName ( )
663- const lastCall = spy . mock . calls [ spy . mock . calls . length - 1 ]
663+ const lastCall = spy . mock . calls . at ( - 1 )
664664
665665 this . assert (
666666 lastCall && equalsArgumentArray ( lastCall , args ) ,
@@ -965,23 +965,23 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
965965 name : 'toHaveLastResolvedWith' ,
966966 condition : ( spy , value ) => {
967967 const result
968- = spy . mock . settledResults [ spy . mock . settledResults . length - 1 ]
969- return (
968+ = spy . mock . settledResults . at ( - 1 )
969+ return Boolean (
970970 result
971971 && result . type === 'fulfilled'
972- && jestEquals ( result . value , value )
972+ && jestEquals ( result . value , value ) ,
973973 )
974974 } ,
975975 action : 'resolve' ,
976976 } ,
977977 {
978978 name : [ 'toHaveLastReturnedWith' , 'lastReturnedWith' ] ,
979979 condition : ( spy , value ) => {
980- const result = spy . mock . results [ spy . mock . results . length - 1 ]
981- return (
980+ const result = spy . mock . results . at ( - 1 )
981+ return Boolean (
982982 result
983983 && result . type === 'return'
984- && jestEquals ( result . value , value )
984+ && jestEquals ( result . value , value ) ,
985985 )
986986 } ,
987987 action : 'return' ,
@@ -992,7 +992,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
992992 const spy = getSpy ( this )
993993 const results
994994 = action === 'return' ? spy . mock . results : spy . mock . settledResults
995- const result = results [ results . length - 1 ]
995+ const result = results . at ( - 1 )
996996 const spyName = spy . getMockName ( )
997997 this . assert (
998998 condition ( spy , value ) ,
0 commit comments