video-* plugins: stim parameter name change and tests #1261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These are the changes from @mgorenstein's pull request (#1171), merged into this branch so that I could also update the documentation and example HTML files with the new parameter name.
I also added tests to each of the plugin test files to make sure that (1) the plugin files are calling the
registerPreload
function, and (2) the parameter name that is used in that function exists in the plugin (to catch thestimulus
/sources
name error that was preventing video preloading before).The easiest way I could think of to test whether an incorrect parameter name was used in
jsPsych.pluginAPI.registerPreload
was to modify jspsych.js so that it produces a console warning if the parameter in thepreloads
list is undefined, and then detect this console warning in the test. This test is working, i.e. it fails whenjsPsych.pluginAPI.registerPreload
uses a parameter name that doesn't exist in the trial object and passes whenstimulus
is used as the parameter name.I couldn't get the
jest.spyOn()
function to work for spying onjsPsych.pluginAPI.registerPreload
. I thought that this would work:const preload_spy = jest.spyOn(jsPsych.pluginAPI, 'registerPreload'); //... set up and run video trial expect(preload_spy).toHaveBeenCalled();
But this always fails, saying thatpreload_spy
was not called. I kept this in the code but commented out theexpect
line to make the tests pass. @jodeleeuw any ideas/suggetions?Also @jodeleeuw I realize that this sort of testing isn't quite what you meant in this comment, but figured this was the quickest way to see if I can get the preload tests working. I can test this in a different way and move the tests somewhere else if you prefer. I think including preload tests somewhere will be useful for #1258.