From ac4272fd56289cadf973c2e9dd78abf52f6ee15a Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Wed, 8 Jan 2025 11:00:43 -0700 Subject: [PATCH] check if `getCitations()` exists in build --- packages/jspsych/tests/citations/citations.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/jspsych/tests/citations/citations.test.ts b/packages/jspsych/tests/citations/citations.test.ts index a03e26c6..93431bd9 100644 --- a/packages/jspsych/tests/citations/citations.test.ts +++ b/packages/jspsych/tests/citations/citations.test.ts @@ -16,12 +16,16 @@ let JsPsych; * This is because the citation functionality is only available in the built version * due to code injections that run during the build. */ - try { // Try to import built version JsPsych = require("../../dist/index").JsPsych; let jspsych: typeof JsPsych; + // Check if getCitations exists in current built version + if (!jspsych.hasOwnProperty("getCitations")) { + throw new Error("getCitations not found"); + } + beforeEach(() => { jspsych = new JsPsych(); }); @@ -35,7 +39,7 @@ try { }); test("citing without input and with invalid format", () => { expect(() => jspsych.getCitations(null, "apa")).toThrow( - "Expected array of plugins/extensions" + "Expected array of plugins/extensionss" ); }); });