Closed fabiocarneiro closed 6 years ago
I see this typically when there's an error in your JavaScript - like a compilation error
I've seen this with an empty test suite too, but I prefer to view my test results in the debug.html - see karma-mocha for example on how to set that up.
Seeing this here also before adding any tests on karma 0.13.19. Agree that this should not be an error (which will cause builds to fail). If I add tests than everything works as expected.
This already done in the master branch and will go out with the next release https://github.com/karma-runner/karma/pull/1796
I have used the karma init and setup a simple test and still get this error.
karma.conf.js // Karma configuration // Generated on Fri Dec 15 2017 13:56:46 GMT-0500 (Eastern Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'lib/**/*.spec.ts'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
File structure
test.component.spec.ts
describe('1st tests', () => {
it('true is true', () => expect(true).toBe(true));
});
Error
I resolved my issue by adding in karma-typescript
$ npm i karma-typescript -D
` // Karma configuration // Generated on Fri Dec 15 2017 13:56:46 GMT-0500 (Eastern Standard Time)
module.exports = function(config) { config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'],
// list of files / patterns to load in the browser
files: [
'lib/**/*.spec.ts'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.ts': ['karma-typescript']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'karma-typescript'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
`
However, I would be open to better ways to resolving this.
Well you could write your in JavaScript, that would also resolve this. Or precompile ts to js.
You are testing in a browser. Browsers run JavaScript. Ergo you have to compile your TypeScript to JavaScript or write in JavaScript in the first place.
Why this is considered a error? I really don't see the error there. I'm doing env bootstrapping and I still have no code, so obviously I have no test, what doesn't mean I should not configure karma to run.
You should at least have a setting to consider this expected behavior, but I really think it should not be considered error by default.