Created
March 27, 2012 13:02
-
-
Save dekokun/2215597 to your computer and use it in GitHub Desktop.
おかしい→おかしくなさそう
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% mocha *.js [~/work/test] | |
.. | |
✖ 1 of 2 tests failed: | |
1) hoge fuga: | |
AssertionError: expected 1 to equal 2 | |
以下エラーメッセージ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var should; | |
should = require("should"); | |
should.test = 2; | |
describe('hoge', function() { | |
return it('fuga', function() { | |
return should.test.should.be.equal(2); | |
}); | |
}); | |
}).call(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var should; | |
should = require("should"); | |
should.test = 1; | |
describe('hoge', function() { | |
return it('fuga', function() { | |
return should.test.should.be.equal(1); | |
}); | |
}); | |
}).call(this); |
いやいやいやいやそれでも書き換えられないのはおかしい。
あーdescribeの中を後から実行するのか。
あとはちゃんとmochaのソースを見てみなくては。
検証の結果、it 及びbeforeEachやらなんやら以外は全部最初にまとめて実行されるといことがわかりました。で、ファイルが違っても同じ名前空間上で実行される。
どうやってそれを実現しているかは、また後のお楽しみですね(今日は寝る)
名前空間は同じじゃないな。module.exportsによってshouldが共有されていたんだ。
片方をgero = require("should")とかに変えてもどうようの事象が発生したため。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あーexportsを通じてお互いにアクセスできそうな感じだなこれ。