Merge pull request #2539 from jspsych/bug-simulation-post-trial-gap

Make `data-only` simulation mode skip any `post_trial_gap` (fix for #2497)
This commit is contained in:
Josh de Leeuw 2022-03-12 18:26:00 -05:00 committed by GitHub
commit ac572d52c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"jspsych": patch
---
Fixed an issue where the `post_trial_gap` was still run in realtime during `data-only` simulation mode. The gap is now skipped as intended.

View File

@ -302,7 +302,9 @@ export class JsPsych {
this.internal.call_immediate = false;
// wait for iti
if (
if (this.simulation_mode === "data-only") {
this.nextTrial();
} else if (
typeof current_trial.post_trial_gap === null ||
typeof current_trial.post_trial_gap === "undefined"
) {

View File

@ -394,4 +394,24 @@ describe("data simulation mode", () => {
await expectFinished();
});
test("Simulation in data-only mode skips post_trial_gap", async () => {
const timeline = [
{
type: htmlKeyboardResponse,
stimulus: "foo",
post_trial_gap: 1000,
},
{
type: htmlKeyboardResponse,
stimulus: "foo",
},
];
const { expectFinished, getData } = await simulateTimeline(timeline);
await expectFinished();
expect(getData().values().length).toBe(2);
});
});