1
Go to list of users who liked
0
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
typescript + karma + mocha + power-assert + browserify メモ
Last updated atPosted at 2016-01-10
なんか選択肢がたくさんあって壮大にハマったのでメモしておきます。
完成形はこれ
TL;DR
結論としてbrowserifyでいく場合は
karma-browserify + tsify + espowerify
でいくのがいいのではと。
karma.conf.jsはこんな感じで書きました。
module.exports = function(config) { config.set({ basePath: '', frameworks: ['mocha', 'browserify'], files: [ 'test/**/*.ts' ], exclude: [ ], preprocessors: { '**/*.ts': ['browserify'] }, browserify: { debug: true, plugin: [ 'tsify' ], transform: ['espowerify'], extensions: ['.ts', '.js'] }, reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['PhantomJS'], singleRun: false, concurrency: Infinity })}あと現在は以下の記事の対応しないとpower-assertの詳細情報がでません。
泣きそうになってたので大変助かりました。
http://qiita.com/wadahiro/items/5d8a81252f2105112339
これ以下は雑なメモです。
雑なメモ
とりあえずnpm initしとく
$ npm initライブラリ
$ npm i karma typescript power-assert karma-browserify tsify espowerify -Dkarma設定
$ npm install -g karma-cli$ karma initWhich testing framework do you want to use ?Press tab to list possible options. Enter to move to the next question.> mochaDo you want to use Require.js ?This will add Require.js plugin.Press tab to list possible options. Enter to move to the next question.> noDo you want to capture any browsers automatically ?Press tab to list possible options. Enter empty string to move to the next question.> PhantomJS> What is the location of your source and test files ?You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".Enter empty string to move to the next question.> Should any of the files included by the previous patterns be excluded ?You can use glob patterns, eg. "**/*.swp".Enter empty string to move to the next question.> Do you want Karma to watch all the files and run the tests on change ?Press tab to list possible options.> yestsconfig.jsonの生成
$ tsc --init編集してこんな感じに
{ "compilerOptions": { "module": "commonjs", "target": "es5", "noImplicitAny": false, "sourceMap": true }, "exclude": [ "node_modules" ]}型定義ファイル
$ tsd init$ tsd install mocha power-assert --saveRegister as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme