I am working on setting up development environment with karma, webpack and typescript, But I am having an issue with karma not applying custom definition file on tests.
This is my project file structure:
// file structure
project/
config/
karma.conf.js
tests/
test-files.ts
...
src/
tsdefinitions.d.ts
other-ts-files.ts
...
tsconfig.json
And here is karma config part related to webpack and typescript
webpack: {
devtool: 'eval-source-map',
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
loaders: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}]
}
},
webpackMiddleware: {stats: 'errors-only'},
mime: {'text/x-typescript': ['ts','tsx']},
basePath: '../',
files: [{
pattern: './test/**/*.ts',
watched: false
}],
preprocessors: {
'./test/**/*.ts': ['webpack', 'sourcemap']
}
And lastly tsconfig.json
{
"compilerOptions": {
"removeComments": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"sourceMap": true,
"noImplicitAny": true,
"allowJs": true,
"module": "commonjs",
"target": "es2015",
"paths": {
"jquery": ["node_modules/jquery/dist/jquery"]
},
"exclude": ["node_modules"],
"files": [
"src/**/*.ts"
]
},
"awesomeTypescriptLoaderOptions": {
"useCache": false,
"useBabel": true,
"babelOptions": {
"presets": [
"es2015",
"stage-0"
]
}
}
}
I am running karma test like this
./node_modules/.bin/karma start ./config/karma.conf.js
Now when I am just building project files using karma everything is ok, they are built with no errors.
But when I am running test build there's a lot of errors of missing Window interface properties that are declared inside tsdefinitions.d.ts file.