I have the following development:
- Angular2 (with Typescript)
- Webpack for packaging
- Karma as a test runner for Jasmine tests
- Gulp to call Karma
Karma is configured as follows:
var webpackConfig = require('./webpack.config'); webpackConfig.entry = {}; module.exports = function(config) { config.set({ basePath: '', // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jasmine'], // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['PhantomJS'], reporters: [], coverageReporter: {}, port: 9876, action: 'run', colors: true, logLevel: config.LOG_INFO, // LOG_DEBUG | LOG_INFO | LOG_WARN | LOG_ERROR autoWatch: false, autoWatchBatchDelay: 300, singleRun: true, files: [ { pattern: './spec-bundle.js', watched: false } ], exclude: [], // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { './spec-bundle.js': ['webpack'] }, webpack: webpackConfig, // https://webpack.imtqy.com/docs/webpack-dev-middleware.html webpackMiddleware: { noInfo: true, stats: 'errors-only' }, plugins: [ 'karma-coverage', 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-teamcity-reporter', 'karma-webpack' ] }); }
Webpack is configured as follows:
var webpack = require('webpack'); module.exports = { entry: { main: './src/run.ts' }, target: 'web', // 'web' | 'node' output: { filename: '[name].js', pathinfo: true }, devtool: 'source-map', resolve: { extensions: ['', '.ts', '.js'] }, resolveLoader: { modulesDirectories: ['node_modules'] }, module: { loaders: [ { test: /\.ts$/, loader: 'ts-loader' }, // fastclick contains AMD and CJS loader logic - disable AMD so CJS is used { test: require.resolve('fastclick'), loader: 'imports?define=>false' } ], postLoaders: [ { test: /\.ts$/, exclude: /(node_modules|spec)\//, loader: 'istanbul-instrumenter' } ] }, stats: { colors: true, errorDetails: true, modules: false, reasons: true // add information about the reasons why modules are included } };
ts is configured as follows:
"compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "moduleResolution": "node", "noEmitHelpers": true, "module": "commonjs", "outDir": "../dist/app", "sourceMap": true }, "buildOnSave": false, "compileOnSave": false }
(/ node_modules is at the same level as / src, and tsconfig.json is in the / src folder).
So, I have a folder / src / typings that contains various * .d.ts files for lodash, fastclick, etc. When I call Karma, I get the following message for each of the definitions:
WARNING in ./src/typings/lodash/lodash.d.ts Module build failed: Error: Typescript emitted no output for /Users/jbrighton/src/teammember-client/src/typings/lodash/lodash.d.ts at Object.loader (/Users/jbrighton/src/teammember-client/node_modules/ts-loader/index.js:456:15) @ ./src \.ts
Jasmine tests succeed (and the non-test build works fine), but what causes these messages and how to prevent them?