Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to mock a library in jest

import randomColor from "randomcolor";


jest.mock("randomColor", () => {
  return {
    randomColor: () => {
      return mockColor('#123456');
    }
  }
});
let mockColor = jest.fn();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mock #library #jest
ADD COMMENT
Topic
Name
8+6 =