I use Webpack for the application and tests (using https://github.com/webpack/karma-webpack for it). The application is in typescript and tests in Babel.
Importing something from a stand-alone module in a test works (using import { cleanHTML, fromHTML, toHTML } from "../../app/utils/text.ts"; that is, I have to mention the .ts extension, otherwise it doesn't will work).
When I actually try to import a React component that imports the component into another file, I get the following error: Module not found: Error: Cannot resolve 'file' or 'directory' ./blocks/paragraph .
The catalog tree is as follows:
src/ app/ components/ blocks/ paragraph.ts main.ts tests/ components/ main_tests.js utils/
And main.ts imports paragraph.ts like this: import { ParagraphBlockComponent } from "./blocks/paragraph";
Normal compilation works, but not tests. Here is the karma config:
var path = require('path'); module.exports = function (config) { config.set({ basePath: 'src', singleRun: true, frameworks: ['mocha', 'chai'], reporters: ['dots'], browsers: ['Firefox'], files: [ 'tests/index.js' ], preprocessors: { 'tests/index.js': ['webpack'] }, webpack: { noInfo: true, module: { loaders: [ { test: /\.ts$/, loaders: ['awesome-typescript-loader'] }, { test: /\_tests.js$/, loaders: ['babel-loader'] } ] } }, webpackMiddleware: { noInfo: true, stats: { color: true, chunkModules: false, modules: false } } }); };
Did I miss something?