티스토리 뷰

28 02 2019 03:11:04.528:ERROR [plugin]: Error during loading "D:\workspace\HyperCube\node_modules/karma-typescript" plugin:

  Cannot find module 'typescript'

28 02 2019 03:11:04.649:ERROR [preprocess]: Can not load "karma-typescript", it is not registered!

  Perhaps you are missing some plugin?

28 02 2019 03:11:04.654:ERROR [karma-server]: Server start failed on port 9876: Error: No provider for "framework:karma-typescript"! (Resolving: framework:karma-typescript)

npm ERR! Test failed.  See above for more details.


Typescript 를 테스트하기 위해서, karma 와 mocha 를 사용하는 환경을 구성하고 테스트를 실행해보았는데 위와 같은 에러를 받았다. 

나의 경우에 해결법은

karma-typescript 모듈을 global 하게 설치함으로써 solve 되었다.

npm install -g karma-typescript




karma.config.js


// Karma configuration
// Generated on Tue Feb 26 2019 21:17:12 GMT+0900 (GMT+09:00)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

plugins : [
'karma-typescript'
],
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'requirejs','chai','karma-typescript'],


// list of files / patterns to load in the browser
files: [
'test-main.js',
{pattern : 'test/**/*.ts',included:true},
{pattern : 'test/*.ts',included:false}
],
karmaTypescriptConfig : {
compilerOptions : {
module : "commonjs"
},
tsconfig : "./tsconfig.json",
},

// list of files / patterns 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: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}


'프로그래밍 언어 > typescript' 카테고리의 다른 글

Karma 에서 node 와 requirejs 의 conflict  (0) 2019.02.28
댓글