Skip to content

Commit

Permalink
Enable typescript for jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala committed Feb 22, 2018
1 parent 9576a66 commit 903c282
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions config/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
window.angular = require('angular');
window.Rx = require('rxjs');
window.$ = require('jquery');
window._ = require('lodash');
window.__ = (x) => x;
window.n__ = (x) => x;
require('../app/assets/javascripts/miq_global');
require('../app/assets/javascripts/miq_application');
require('../app/assets/javascripts/miq_api');
require('../app/assets/javascripts/miq_angular_application');
11 changes: 10 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ module.exports = {
__testing__: true
},
roots: ['app/javascript'],
testMatch: ['**/*.test.js']
setupFiles: ['./config/jest.setup.js'],
testRegex: '(/__tests__/.*|(\\.|_|/)(test|spec))\\.(js?|ts?)$',
transform: {
'^.+\\.js$': 'babel-jest',
'.(ts|tsx)': 'ts-jest'
},
moduleFileExtensions: [
'ts',
'js'
],
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@angular/platform-browser-dynamic": "~4.0.3",
"angular": "~1.6.6",
"angular-animate": "~1.6.6",
"angular-mocks": "~1.6.6",
"angular-sanitize": "~1.6.6",
"core-js": "~2.4.1",
"lodash": "^4.17.4",
Expand All @@ -43,7 +42,11 @@
},
"devDependencies": {
"@types/angular": "1.6.29",
"@types/angular-mocks": "^1.5.11",
"@types/jasmine": "^2.8.6",
"@types/jest": "^22.1.3",
"@types/redux": "^3.6.0",
"angular-mocks": "^1.6.9",
"autoprefixer": "~6.7.7",
"babel-core": "~6.24.1",
"babel-eslint": "~6.0.4",
Expand Down Expand Up @@ -86,6 +89,7 @@
"style-loader": "~0.16.1",
"stylelint": "^8.2.0",
"stylelint-config-standard": "^17.0.0",
"ts-jest": "^22.0.4",
"ts-loader": "~2.0.3",
"typescript": "~2.2.2",
"webpack": "~3.2.0",
Expand Down

0 comments on commit 903c282

Please sign in to comment.