我的简化$request_json["attributes"] = array( //Add attributes that we send to Open Athens
"Userid" => str_replace(" ","",$user_uid),
"Fullname" => $jsonRestData->RECORD[0]->FULLNAME,
"Email" => $jsonRestData->RECORD[0]->STUDENT_EMAIL,
"Role" => $jsonRestData->RECORD[0]->LOGIN_STATUS_TEXT,
"Year" => $jsonRestData->RECORD[0]->STUDENT_ACADEMIC_YEAR,
"Department" = array($jsonRestData->RECORD[0]->STUDENT_DEPARTMENT, $jsonRestData->RECORD[1]->STUDENT_DEPARTMENT),
"Speciality" = array($jsonRestData->RECORD[0]->STUDENT_SPECIALITY, $jsonRestData->RECORD[1]->STUDENT_SPECIALITY),
"permissionSets" => "qsm#default"
);
是:
jest.config.js
moduleNameMapper映射到任何级别的嵌套路径:
我正在像module.exports = {
preset: "ts-jest",
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.ts",
"!**/node_modules/**",
"!src/config/*.ts",
"!build/**/*"
],
coverageReporters: ["text"],
reporters: ["default"],
moduleDirectories: [
"src",
"node_modules"
],
moduleNameMapper: {
"@helpers/(.*)": "<rootDir>/src/helpers/$1", <---- question about this
},
globals: {
'ts-jest': {
diagnostics: {
pathRegex: /\.(spec|test)\.ts$/,
ignoreCodes: [6133]
}
}
},
verbose: true,
roots: ["src"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx"]
};
这样的测试中使用它
但是,出现此错误:
无法找到映射为的模块
import foo from "@helpers/foo/foo";
:@helpers/foo
在文档中找不到有关嵌套路径的任何内容。我假设,由于/<PATH>/src/helpers/foo
是一个正则表达式,因此应该可以立即使用。
我在做什么错?也许是个错误?