Skip to content

Instantly share code, notes, and snippets.

@oyilmaztekin
Last active September 10, 2019 07:08
Show Gist options
  • Select an option

  • Save oyilmaztekin/f649ce4635fb72c280ea3fae07a24cb9 to your computer and use it in GitHub Desktop.

Select an option

Save oyilmaztekin/f649ce4635fb72c280ea3fae07a24cb9 to your computer and use it in GitHub Desktop.
Jest Configuration
/* eslint-disable */
module.exports = function (api) {
api.cache(false);
if (process.env.NODE_ENV === "test") {
console.log("env: " + process.env.NODE_ENV);
return {
presets: [
"@babel/preset-react",
[
"@babel/preset-env",
{
targets: {
"node": process.versions.node
}
}
]
],
"plugins": [
["@babel/plugin-proposal-decorators", {legacy: true}],
[
"@babel/plugin-proposal-class-properties",
{loose: true}
],
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-object-assign",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime",
"@babel/plugin-transform-modules-commonjs"
]
};
}
.....
}
/* eslint-disable */
module.exports = {
"verbose": true,
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.jsx$": "babel-jest",
"^.+\\.(css|scss|less|sass)$": "<rootDir>/mocks/styleMock.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/mocks/fileMock.js"
},
"moduleNameMapper":{
"^.+\\.(css|scss|less|sass)$": "<rootDir>/mocks/styleMock.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/mocks/fileMock.js"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/*.json",
"<rootDir>/stories/",
"<rootDir>/mocks/"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/*.json",
"<rootDir>/stories/"
],
"globals": {
"NODE_ENV": "test"
},
"moduleFileExtensions": [
"js",
"jsx",
"json"
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment