i trying automate unit test execution using grunt karma , karma-typescript-preprocessor.
however, when run 'grunt watch', karma outputs following error : error [preprocessor.typescript]: /home/loic/code/appname/src/app/app.spec.ts.ktp.ts(15,13): error ts2304: cannot find name 'expect'.
this error happens lot of names : 'describe, angular, expect 'etc
the strange thing when run command line 'tsc /path/to/app.spec.ts', new js file created, there no error.
below karma.conf.js :
module.exports = function ( karma ) { karma.set({ /** * files, starting location of file. */ basepath: '../', typescriptpreprocessor: { // options passed typescript compiler options: { sourcemap: false, // (optional) generates corresponding .map file. target: 'es5', // (optional) specify ecmascript target version: 'es3' (default), or 'es5' module: 'amd', // (optional) specify module code generation: 'commonjs' or 'amd' noimplicitany: false, // (optional) warn on expressions , declarations implied 'any' type. noresolve: true, // (optional) skip resolution , preprocessing. removecomments: true // (optional) not emit comments output. }, // transforming filenames transformpath: function(path) { return path.replace(/\.ts$/, '.js'); } }, /** * list of file patterns load browser during testing. */ files: [ <% scripts.foreach( function ( file ) { %>'<%= file %>', <% }); %> 'src/**/*.ts' ], exclude: [ 'src/assets/**/*.ts', 'src/typescript/**/*.ts' ], frameworks: [ 'jasmine' ], plugins: [ 'karma-jasmine', 'karma-firefox-launcher', 'karma-typescript-preprocessor' ], preprocessors: { '**/*.ts': 'typescript' }, /** * how report, default. */ reporters: 'dots', /** * on port should browser connect, on port test runner * operating, , url path browser use. */ port: 9018, runnerport: 9100, urlroot: '/', /** * disable file watching default. */ autowatch: false, /** * list of browsers launch test on. includes "firefox" * default, other browser names include: * chrome, chromecanary, firefox, opera, safari, phantomjs * * note can use executable name of browser, "chromium" * or "firefox", these vary based on operating system. * * may leave blank , manually navigate browser * http://localhost:9018/ when you're running tests. window/tab can left * open , tests automatically occur there during build. has * aesthetic advantage of not launching browser every time save. */ browsers: [ 'firefox' ] }); };
any appreciated
try removing line
noresolve: true,
from typescriptpreprocessor configuration. seems cause compiler not resolve references properly.