You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I coded up a face-name experiment and wrote some unit tests for it. Everything worked great, but it lacked image preloading. Once I added it, my unit tests broke because image preloading appears to halt the timeline in the jest environment. Whenever I examine getDisplayElement().innerHTML it's always a progress bar.
I've tried the following variations on mocking/stubbing image preloading:
jsPsych.pluginAPI.preloadImages = jest.fn((x, cb) => { cb(); }); // taken from the jsPsych preload unit test
jsPsych.pluginAPI.preloadImages = jest.fn();
jsPsych.pluginAPI.preloadImages = () => {};
jest.spyOn(jsPsych.pluginAPI, "preloadImages").mockImplementation(() => null);
...all to no avail. All of these attempts happen in my beforeEach block before I call jsPsych.init:
Any suggestions on what I can do to essentially ignore image preloading in my test environment? Unless anyone has any other ideas I'll probably just modify the timeline in my test env to get rid of the preload step, though that doesn't seem ideal.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I coded up a face-name experiment and wrote some unit tests for it. Everything worked great, but it lacked image preloading. Once I added it, my unit tests broke because image preloading appears to halt the timeline in the jest environment. Whenever I examine getDisplayElement().innerHTML it's always a progress bar.
I've tried the following variations on mocking/stubbing image preloading:
...all to no avail. All of these attempts happen in my beforeEach block before I call jsPsych.init:
Any suggestions on what I can do to essentially ignore image preloading in my test environment? Unless anyone has any other ideas I'll probably just modify the timeline in my test env to get rid of the preload step, though that doesn't seem ideal.
Beta Was this translation helpful? Give feedback.
All reactions