From c8bda3c35b333c4e12db9d38a304e5385baae671 Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Fri, 10 Jan 2025 01:52:45 -0700 Subject: [PATCH] reactivate old test, remove deprecated `toThrowError()` calls --- packages/jspsych/src/timeline/Timeline.spec.ts | 4 ++-- packages/jspsych/src/timeline/Trial.spec.ts | 2 +- packages/jspsych/tests/core/timeline-variables.test.ts | 9 ++++----- .../jspsych/tests/randomization/randomization.test.ts | 2 +- .../plugin-video-keyboard-response/src/index.spec.ts | 2 +- packages/plugin-video-slider-response/src/index.spec.ts | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/jspsych/src/timeline/Timeline.spec.ts b/packages/jspsych/src/timeline/Timeline.spec.ts index 88688c37..8d6d6743 100644 --- a/packages/jspsych/src/timeline/Timeline.spec.ts +++ b/packages/jspsych/src/timeline/Timeline.spec.ts @@ -586,10 +586,10 @@ describe("Timeline", () => { const variable = new TimelineVariable("x"); await timeline.run(); - expect(() => timeline.evaluateTimelineVariable(variable)).toThrowError(""); + expect(() => timeline.evaluateTimelineVariable(variable)).toThrow(); expect(() => (timeline.children[0] as Timeline).evaluateTimelineVariable(variable) - ).toThrowError(""); + ).toThrow(); }); }); }); diff --git a/packages/jspsych/src/timeline/Trial.spec.ts b/packages/jspsych/src/timeline/Trial.spec.ts index e26e02c6..2a532262 100644 --- a/packages/jspsych/src/timeline/Trial.spec.ts +++ b/packages/jspsych/src/timeline/Trial.spec.ts @@ -524,7 +524,7 @@ describe("Trial", () => { ); await expect( createTrial({ type: TestPlugin, requiredComplexNested: {} }).run() - ).rejects.toThrowError('"requiredComplexNested.requiredChild" parameter'); + ).rejects.toThrow('"requiredComplexNested.requiredChild" parameter'); }); it("errors on missing parameters nested in `COMPLEX` array parameters", async () => { diff --git a/packages/jspsych/tests/core/timeline-variables.test.ts b/packages/jspsych/tests/core/timeline-variables.test.ts index 7bd1e8cd..c903dc26 100644 --- a/packages/jspsych/tests/core/timeline-variables.test.ts +++ b/packages/jspsych/tests/core/timeline-variables.test.ts @@ -400,8 +400,7 @@ describe("timeline variables are correctly evaluated", () => { }); }); -// using console.warn instead of error for now. plan is to enable this test with version 8. -test.skip("timelineVariable() throws an error when variable doesn't exist", async () => { +test("throws an error when variable doesn't exist", async () => { const jsPsych = initJsPsych(); const { expectFinished } = await startTimeline( [ @@ -411,7 +410,7 @@ test.skip("timelineVariable() throws an error when variable doesn't exist", asyn type: htmlKeyboardResponse, stimulus: "foo", on_start: () => { - expect(() => jsPsych.evaluateTimelineVariable("c")).toThrowError(); + expect(() => jsPsych.evaluateTimelineVariable("c")).toThrow(); }, }, ], @@ -430,7 +429,7 @@ test.skip("timelineVariable() throws an error when variable doesn't exist", asyn await expectFinished(); }); -test("timelineVariable() can fetch a variable called 'data'", async () => { +test("can fetch a variable called 'data'", async () => { const jsPsych = initJsPsych(); const { expectFinished } = await startTimeline( [ @@ -440,7 +439,7 @@ test("timelineVariable() can fetch a variable called 'data'", async () => { type: htmlKeyboardResponse, stimulus: "foo", on_start: () => { - expect(() => jsPsych.evaluateTimelineVariable("data")).not.toThrowError(); + expect(() => jsPsych.evaluateTimelineVariable("data")).not.toThrow(); }, }, ], diff --git a/packages/jspsych/tests/randomization/randomization.test.ts b/packages/jspsych/tests/randomization/randomization.test.ts index ac5d13e8..7562fe0c 100644 --- a/packages/jspsych/tests/randomization/randomization.test.ts +++ b/packages/jspsych/tests/randomization/randomization.test.ts @@ -198,7 +198,7 @@ describe("randomInt", () => { test("setting upper < lower throws an error", () => { expect(() => { randomInt(1, 0); - }).toThrowError(); + }).toThrow(); }); }); diff --git a/packages/plugin-video-keyboard-response/src/index.spec.ts b/packages/plugin-video-keyboard-response/src/index.spec.ts index 8772f81e..e0ac5f0a 100644 --- a/packages/plugin-video-keyboard-response/src/index.spec.ts +++ b/packages/plugin-video-keyboard-response/src/index.spec.ts @@ -23,7 +23,7 @@ describe("video-keyboard-response", () => { await expect(async () => { await jsPsych.run(timeline); - }).rejects.toThrowError(); + }).rejects.toThrow(); }); }); diff --git a/packages/plugin-video-slider-response/src/index.spec.ts b/packages/plugin-video-slider-response/src/index.spec.ts index 3aabbefc..d5b4662e 100644 --- a/packages/plugin-video-slider-response/src/index.spec.ts +++ b/packages/plugin-video-slider-response/src/index.spec.ts @@ -22,7 +22,7 @@ describe("video-slider-response", () => { await expect(async () => { await jsPsych.run(timeline); - }).rejects.toThrowError(); + }).rejects.toThrow(); }); });