LoginSignup
8
7

More than 5 years have passed since last update.

Coffee-script+mochaコンパイルせずにテスト

Posted at

まずはインストール、sudoの必要があるかもしれません。

$ npm install coffee-script -g
$ npm install mocha -g

mocha.optsにcoffee-scriptを追加。

/test/mocha.opts
--compilers coffee:coffee-script

後はそのまま.coffeeのテストを書くだけです。
テストする時は:

$ mocha

コードを読みやすく、package.json、又はCakefileにテストコマンドを書いておく。

ソースコードもコンパイルせずにテスト、例えば./index.coffeeのテスト、ここではChaiassertを使います。

./test/test.index.coffee
{assert} = require('chai')
target = require '../src/index'

describe 'Constant', ->
  it 'should work', ->
    assert.ok target?
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7