To use the jest configuration in your IDE, or to add customisation
- Create an
jest.config.js
at your project root folder - Make it extend the one from talend preset
const defaults = require('@talend/scripts-config-jest');
module.exports = {
...defaults,
// add/change default config here
};
because jest support of ECMAPScriptModules is experiemental we have added possibilities to apply transforms on modules. Since d3 7.x library use ECMAPScriptModules in it's package.json as main entry point it break jest with this kind of errors:
node_modules/d3-scale/src/index.js:1
export {
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
You may encounter in your project the need to add other modules than just d3. To do so we provide to you the following API:
// your project's jest.config.js
const config = require('@talend/scripts-config-jest/jest.config.js');
const testUtils = require('@talend/scripts-config-jest/utils');
testUtils.applyBabelTransformOn(config, ['dexie']);
module.exports = config;