RequireJSとJasmineを使用した単体テスト戦略で依存性注入を探しています。私はtestrの背後にあるアイディアが本当に好きで、githubの例に続いてtestrをセットアップしようとしましたが、何が間違っているのか分かりません。私はいつもエラーが発生するRequireJS、Jasmine、testrを使用したJavaScript依存性注入
Error: module has not been loaded: today
テストしようとしているモジュールをロードしようとすると、ここで
いくつかのコンテキスト..
index.htmlを ...
<script data-main="config" src="../../assets/js/libs/require.js"></script>
<script src="vendor/testr.js"></script>
config.jsの ...
require.config({
// Initialize specs.
deps:["main"],
...
...
});
main.js ..
require([
// Load the example spec, replace this and add your own spec
"spec/today"
], function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.execute();
});
today.jsスペック\ ..
today.jsdescribe('Today print', function() {
var date = {}, today;
beforeEach(function() {
date.today = new Date(2012, 3, 30);
today = testr('today', {'util/date': date}); //Here is where the error is thrown
});
it('is user-friendly', function() {
expect(today.getDateString()).toBe('Today is Monday, 30th April, 2012');
});
});
...
define(['string', 'util/date'], function(string, date) {
return {
getDateString: function() {
return string.format('Today is %d', date.today);
}
}
});
とされている誰もがあります同じ種類のトラブル? 。私はRequireJS 2.0.6を使用しています
ありがとうございました。
大丈夫 のようなものを試してみてください。私はtestrがすぐに数日間働いていることに取り組んできました。これは、私がサンプルプロジェクトを見に来たことに最も近いものです。私はジャスミンを使って他の人と分かち合うために、この例のgithub repoを作成しました。しかし、それはまだ動作していません。誰も助けてくれますか?ありがとう。 https://github.com/loesak/jasmine-maven-require-testr – loesak
私は同じ問題を抱えています。実際、require.configのdepとして手動でロードし、カルマはファイルが要求されていることを示します(最初)。 – FlavorScape