Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from datavisyn/stoiber/testing_with_jest
Browse files Browse the repository at this point in the history
Use Jest for testing
  • Loading branch information
Anita Steiner authored Mar 27, 2020
2 parents 21e0131 + bfb9684 commit c60fa60
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
55 changes: 55 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// test dependencies that require transformation
let pluginsToTransform = [
'tdp_*',
'phovea_*',
'lineupjs'
].join('|');

if(pluginsToTransform.length > 0) {
/** Attention: Negative Lookahead! This regex adds the specified repos to a whitelist that holds plugins that are excluded from the transformIgnorePatterns.
* This means that pluginsToTransform should contain all repos that export ts files. They can only be handled by the transformation. */
pluginsToTransform = `(?!${pluginsToTransform})`;
}

/**
* TODO check if we can process inline webpack loaders (e.g. as found in https://github.com/phovea/phovea_ui/blob/master/src/_bootstrap.ts)
* see also https://jestjs.io/docs/en/webpack#mocking-css-modules
*/
module.exports = {
transform: {
"^.+\\.tsx?$": "ts-jest",
"\\.xml$": "jest-raw-loader"
},
testRegex: "(.*(test|spec))\\.(tsx?)$",
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
modulePaths: [
"src",
"../node_modules",
"../"
],
transformIgnorePatterns: [`../node_modules/${pluginsToTransform}`, `node_modules/${pluginsToTransform}`],
globals: {
"__VERSION__": "TEST_VERSION",
"__APP_CONTEXT__": "TEST_CONTEXT",
'ts-jest': {
// has to be set to true, otherwise i18n import fails
"tsConfig": {
"esModuleInterop": true,
}
}
},
moduleNameMapper: {
"^.+\\.(css|less|scss|sass|png|jpg|gif)$": "identity-obj-proxy",
"imports-loader?.*": "imports-loader",
"raw-loader?.*": "raw-loader",
"file-loader?.*": "file-loader",
"script-loader?.*": "script-loader"
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@types/d3-brush": "^1.0.8",
"@types/d3-drag": "^1.2.1",
"@types/d3-format": "^1.3.0",
"@types/jest": "25.1.4",
"@types/d3-polygon": "^1.0.6",
"cache-loader": "^1.2.2",
"css-loader": "^1.0.0",
Expand All @@ -89,7 +90,10 @@
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^1.1.11",
"fork-ts-checker-webpack-plugin": "^0.4.4",
"jest": "25.1.0",
"jest-raw-loader": "1.0.1",
"json-loader": "^0.5.7",
"identity-obj-proxy": "^3.0.0",
"mkdirp": "^0.5.1",
"node-sass": "^4.12.0",
"raw-loader": "^1.0.0-beta.0",
Expand All @@ -104,6 +108,7 @@
"tslint": "^5.11.0",
"tslint-consistent-codestyle": "^1.13.3",
"tslint-eslint-rules": "^5.3.1",
"ts-jest": "25.2.1",
"typedoc": "^0.11.1",
"typedoc-plugin-as-member-of": "^1.0.2",
"typescript": "^3.0.1",
Expand Down

0 comments on commit c60fa60

Please sign in to comment.