'JEST with Handlebars configuration
I am trying to add Jest to existing project and i have problem with configuration.
- To solve problem with modules and es6 i added rollup-jest package (we are using rollup on our project)
- To solve problem with handlebars i tried to use jest-handlebars package but i got problem
Code transformer's `process` method must return an object containing `code` key
with processed string. If `processAsync` method is implemented it must return
a Promise resolving to an object containing `code` key with processed string.
Code Transformation Documentation:
https://jestjs.io/docs/code-transformation```
Has anybody aby similar problem with jest plus handlebars configuration or can anybody help me with code transformator?
EDIT:
i added preprocessor.js file with:
module.exports = {
process(src) {
const code = `
const Handlebars = require('handlebars');
module.exports = Handlebars.compile(\`${src}\`);
`
return {
code: code
};
},
};
and change my packaged.json to:
``` "jest": {
"preset": "rollup-jest",
"collectCoverage": true,
"modulePaths": [
"./",
"./node_modules"
],
"moduleFileExtensions": [
"js",
"hbs",
"ts"
],
"transform": {
"\\.js$": "rollup-jest",
"^.+\\.hbs$": "<rootDir>/jestHbsTransformer.js",
"^.+\\.ts?$": "ts-jest"
}
}
}```
and it is still not working ;)
enter code here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
