Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jest mock implementation once

const myMockFn = jest
  .fn()
  .mockImplementationOnce(cb => cb(null, true))
  .mockImplementationOnce(cb => cb(null, false));

myMockFn((err, val) => console.log(val));
// > true

myMockFn((err, val) => console.log(val));
// > false
Source by jestjs.io #
 
PREVIOUS NEXT
Tagged: #jest #mock #implementation
ADD COMMENT
Topic
Name
5+8 =