Skip to content

Commit

Permalink
Add support for *.ts files in karma tests (#350)
Browse files Browse the repository at this point in the history
* #219 Downgrades karma to v4 to add support for *.ts files
* #219 - Removes unnecessary devDep
* #219 - Upgrades karma to v5 to fix vulnerability
  • Loading branch information
swistach committed May 11, 2020
1 parent 014274b commit 6d29745
Show file tree
Hide file tree
Showing 6 changed files with 946 additions and 590 deletions.
21 changes: 18 additions & 3 deletions .config/karma/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports.create = function(config) {

// list of files / patterns to load in the browser
files: [
'karma.starter.js',
'karma.starter.ts',
],

// list of files / patterns to exclude
Expand All @@ -18,7 +18,7 @@ module.exports.create = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'karma.starter.js': ['webpack', 'sourcemap'],
'karma.starter.ts': ['webpack', 'sourcemap'],
},

// test results reporter to use
Expand Down Expand Up @@ -54,7 +54,22 @@ module.exports.create = function(config) {
// Webpack's configuration for Karma
webpack: {
mode: 'development',
devtool: 'inline-source-map',
devtool: 'cheap-module-eval-source-map',
module: {
rules: [
{
test: /\.ts?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: 'tsconfig.test.json'
}
},
],
},
resolve: {
extensions: [ '.ts', '.js' ],
},
},
};
};
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ node_modules

# Configurations
*.config.js
karma.*.js
karma.*
doc

# Aut-generated directiories
Expand Down
4 changes: 2 additions & 2 deletions karma.starter.js → karma.starter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './test-jasmine/test/_setupFiles/bootstrap';
import './test/_setupFiles/bootstrap';

// require all modules ending in ".spec.js" from the
// './temp-browser/test' directory and all subdirectories
const testsContext = require.context('./test-jasmine', true, /.spec.js$/);
const testsContext = require.context('./test', true, /.spec.ts$/);

testsContext.keys().forEach(testsContext);
Loading

0 comments on commit 6d29745

Please sign in to comment.