2016-03-19 4 views
1

イムは、カルマ、ジャスミンと協力している...しかしありませんカルマ・モカ....私karma.confファイルでの作業: -不明なエラー:モジュール名「のlib /チャイ」は、コンテキストのためにロードされていない:使用カルマ・モカ..myのkarma.confファイルを使用して([])が必要です

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

    basePath : '../app', 

    preprocessors: { 
     '**/*.html':'ng-html2js' 
    }, 

    ngHtml2JsPreprocessor: { 
     prependPrefix: '/' 
    }, 

    files : [ 
    'node_modules/jquery/**/*.js', 
     'lib/angular/angular.js', 
     'lib/angular/angular-*.js', 
     '../test/lib/angular-mocks.js', 
     '../test/lib/sinon-1.15.0.js', 
     '../test/chai/chai.js', 
     'js/**/*.js', 
     '../test/unit/**/*.js', 
     '**/*.html' 
    ], 

    autoWatch : true, 

    frameworks: ['mocha','requirejs','chai'], 

    browsers : ['Chrome'], 

    plugins : [ 
     'karma-chrome-launcher', 
     'karma-mocha', 
     'karma-ng-html2js-preprocessor', 
     'karma-requirejs', 
     'karma-chai' 
    ], 

    junitReporter : { 
     outputFile: 'test_out/unit.xml', 
     suite: 'unit' 
    } 

    }); 
}; 
+0

コンソールでエラーが発生しましたか? –

+0

@RIYAJ KHANすべてがジャスミンとうまくいっていた。私はそうは思わない。 RIYAJ KHAN JI @ –

答えて

0

あなたはそれをmocha.includeする依存関係であるchai libパスfiles arrayが欠落しています。

files : [ 
     'node_modules/jquery/**/*.js', 
      'lib/angular/angular.js', 
      'lib/angular/angular-*.js', 
      '../test/lib/angular-mocks.js', 
      '../test/lib/sinon-1.15.0.js', 
      '../test/chai/chai.js', 
      'js/**/*.js', 
      '../test/unit/**/*.js', 
      '**/*.html' 
     ], 
+0

はまだ私は..... クローム49.0.2623(Windows 7の0.0.0)ERROR 不明なエラーが同じエラーを取得M:_:モジュール名 "チャイ" コンテキストのためにロードされていません。/6-angularjs-fundamentals-m6-testing-exercise-files/Finished/DemoApp/nodeに require([]) http://requirejs.org/docs/errors.html#notloaded を使用してください _modules/requirejs/require.js:143 –

+0

テストスクリプトを共有してください –

+0

これはスクリプトの1つのモジュールです。 'use strict'; var chai = require( 'chai'); expect = chai.expect; chai.should(); は( 'calendarHelper'、関数(){記述 beforeEach(モジュール( 'eventsApp')); それ(({)( 期待する機能(calendarHelperを注入し、 'ゼロ与えられた場合月返すべき' calendarHelper .getMonthName(0))被( '1月'); })) })。 –

-1

ジャスミンと同様の状況に遭遇しました。 私のソリューションを紹介したいと思います。

は、エラーメッセージに書かれているもの、それを試してみてください。ウェブサイトへのリンクがあります:http://requirejs.org/docs/errors.html#notloaded

//If this code is not in a define call, 
//DO NOT use require('foo'), but use the async 
//callback version: 
require(['foo'], function (foo) { 
    //foo is now loaded. 
}); 

コーヒースクリプトでジャスミンのために書かれた私の場合は、次のようになります。

sinon = require(['sinon', 'jasmine-sinon']) (foo)-> 

今、私はまた私のユニットテストでオブジェクトとしてsinonを使用するとことができsinonとjasmin-sinonの文書に従ってください。

+0

を待っ '**ない**モジュール、ライン'のでsinon =必要とされる依存関係の配列を呼び出すrequire' ([...]) 'は正しいことができません。 – Louis

+0

あなたは "sinon ="なしで試してみるのですか?その後何が起こるのですか? – LSR

+0

最初のスニペットで示したコールバックフォームを使用する必要があります。 – Louis

関連する問題