Expand my Community achievements bar.

SOLVED

How to mock a statement in JEST

Avatar

Employee

Hi,

 

I have the following statement in my client library function

$(window).adaptTo("foundation-ui");

 

I am not able to understand how to mock this line in JEST so that it skips this line

Please can anybody help

Thanks

Tarini

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You'd ned to mock the adapTo function like the example below:

$.fn.adaptTo = jest.fn().mockImplementation(() => {
  // Mock implementation goes here
});

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

You'd ned to mock the adapTo function like the example below:

$.fn.adaptTo = jest.fn().mockImplementation(() => {
  // Mock implementation goes here
});