mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00

Instead of a global `jsPsych` object, there is a `JsPsych` class now which can be instantiated with the parameters that were previously accepted by `jsPsych.init`. Upon instantiation, the `JsPsych` class also instantiates classes for stateful modules (`jsPsych.data` and `jsPsych.pluginAPI`) and passes relevant `JsPsych` instance information to them. Plugins are expected to be classes now that are instantiated for each trial and receive the `JsPsych` instance as their only constructor argument.
32 lines
1016 B
JavaScript
32 lines
1016 B
JavaScript
const ts = require("typescript");
|
|
const { pathsToModuleNameMapper } = require("ts-jest/utils");
|
|
|
|
module.exports.makePackageConfig = (dirname) => {
|
|
const packageJson = require(dirname + "/package.json");
|
|
const packageBaseName = packageJson.name.replace("@jspsych/", "");
|
|
|
|
// based on https://github.com/formium/tsdx/blob/462af2d002987f985695b98400e0344b8f2754b7/src/createRollupConfig.ts#L51-L57
|
|
const tsCompilerOptions = ts.parseJsonConfigFileContent(
|
|
ts.readConfigFile(dirname + "/tsconfig.json", ts.sys.readFile).config,
|
|
ts.sys,
|
|
dirname
|
|
).options;
|
|
|
|
return {
|
|
preset: "ts-jest",
|
|
moduleNameMapper: pathsToModuleNameMapper(tsCompilerOptions.paths, {
|
|
prefix: "<rootDir>/",
|
|
}),
|
|
testEnvironment: "jsdom",
|
|
testEnvironmentOptions: {
|
|
fetchExternalResources: true,
|
|
pretendToBeVisual: true,
|
|
},
|
|
testURL: "http://localhost/",
|
|
displayName: {
|
|
name: packageBaseName,
|
|
color: packageBaseName === "jspsych" ? "white" : "cyanBright",
|
|
},
|
|
};
|
|
};
|