Hi All, has any one worked out how to get Jest wor...
# sdf
t
Hi All, has any one worked out how to get Jest working with the @NAmdConfig /SuiteScripts/Library/myConfiguration.json? everytime I run it says it fails to find the things listed in the myConfiguration.json
s
Hey @Tim Pilgrim!! I haven’t tried with Jest, but the @NAmdConfig tag doesn’t work in library or module files.. it must be in the script entry point, at least for SuiteScript files.
t
that is an interesting point I include the "NAmdConfig" tag in the module/library and also include the "NAmdConfig" tag in the scripts that include the library but your right I will test on a UE script and see if the include then works with Jest.... stay tuned
worked it out..... you have to add the moduleNameMapper to your jest.config.js module.exports
🙌 1
e
@Tim Pilgrim Could you post an example configuration? I ended up having to specify relative path for these modules on scripts I was testing. I’d love to go back.
t
Jest config
Copy code
let myConfig = SuiteCloudJestConfiguration.build({
    projectFolder: cliConfig.defaultProjectFolder,
    projectType: SuiteCloudJestConfiguration.ProjectType.ACP
});
module.exports = {
    ...myConfig,
    moduleNameMapper: {
        ...myConfig.moduleNameMapper,
        "moment": "<rootDir>/src/FileCabinet/SuiteScripts/SuiteFunction/Library/moment/moment.min"
    }
}
and this is my NAmdConfig
Copy code
{
  "paths": {
    "moment": "/SuiteScripts/SuiteFunction/Library/moment/moment.min.js"
  }
}
as you can see its the same paths just declared slightly differently.