reactivate old test, remove deprecated toThrowError() calls

This commit is contained in:
jade 2025-01-10 01:52:45 -07:00
parent ad1d854f43
commit c8bda3c35b
6 changed files with 10 additions and 11 deletions

View File

@ -586,10 +586,10 @@ describe("Timeline", () => {
const variable = new TimelineVariable("x"); const variable = new TimelineVariable("x");
await timeline.run(); await timeline.run();
expect(() => timeline.evaluateTimelineVariable(variable)).toThrowError(""); expect(() => timeline.evaluateTimelineVariable(variable)).toThrow();
expect(() => expect(() =>
(timeline.children[0] as Timeline).evaluateTimelineVariable(variable) (timeline.children[0] as Timeline).evaluateTimelineVariable(variable)
).toThrowError(""); ).toThrow();
}); });
}); });
}); });

View File

@ -524,7 +524,7 @@ describe("Trial", () => {
); );
await expect( await expect(
createTrial({ type: TestPlugin, requiredComplexNested: {} }).run() 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 () => { it("errors on missing parameters nested in `COMPLEX` array parameters", async () => {

View File

@ -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("throws an error when variable doesn't exist", async () => {
test.skip("timelineVariable() throws an error when variable doesn't exist", async () => {
const jsPsych = initJsPsych(); const jsPsych = initJsPsych();
const { expectFinished } = await startTimeline( const { expectFinished } = await startTimeline(
[ [
@ -411,7 +410,7 @@ test.skip("timelineVariable() throws an error when variable doesn't exist", asyn
type: htmlKeyboardResponse, type: htmlKeyboardResponse,
stimulus: "foo", stimulus: "foo",
on_start: () => { 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(); await expectFinished();
}); });
test("timelineVariable() can fetch a variable called 'data'", async () => { test("can fetch a variable called 'data'", async () => {
const jsPsych = initJsPsych(); const jsPsych = initJsPsych();
const { expectFinished } = await startTimeline( const { expectFinished } = await startTimeline(
[ [
@ -440,7 +439,7 @@ test("timelineVariable() can fetch a variable called 'data'", async () => {
type: htmlKeyboardResponse, type: htmlKeyboardResponse,
stimulus: "foo", stimulus: "foo",
on_start: () => { on_start: () => {
expect(() => jsPsych.evaluateTimelineVariable("data")).not.toThrowError(); expect(() => jsPsych.evaluateTimelineVariable("data")).not.toThrow();
}, },
}, },
], ],

View File

@ -198,7 +198,7 @@ describe("randomInt", () => {
test("setting upper < lower throws an error", () => { test("setting upper < lower throws an error", () => {
expect(() => { expect(() => {
randomInt(1, 0); randomInt(1, 0);
}).toThrowError(); }).toThrow();
}); });
}); });

View File

@ -23,7 +23,7 @@ describe("video-keyboard-response", () => {
await expect(async () => { await expect(async () => {
await jsPsych.run(timeline); await jsPsych.run(timeline);
}).rejects.toThrowError(); }).rejects.toThrow();
}); });
}); });

View File

@ -22,7 +22,7 @@ describe("video-slider-response", () => {
await expect(async () => { await expect(async () => {
await jsPsych.run(timeline); await jsPsych.run(timeline);
}).rejects.toThrowError(); }).rejects.toThrow();
}); });
}); });