0

単体テストで jasmine-jquery を使用して BackboneJS ビューをテストしようとしていますが、テストを実行しようとすると次のエラーが発生します。

「jasmine:src」(ジャスミン)タスクの実行

PhantomJS によるジャスミン仕様のテスト

TypeError: 'undefined' はオブジェクトではありません ('jasmine.spiedEventsKey = function (selector, eventName) { return [$(selector).selector, eventName].toString() }') を評価します)

テスト/ベンダー/jasmine-jquery-master/lib/jasmine-jquery.js:40

テスト/ベンダー/jasmine-jquery-master/lib/jasmine-jquery.js:34

テスト/ベンダー/jasmine-jquery-master/lib/jasmine-jquery.js:838

grunt、phantomjs、grunt-contrib-jasmine タスク、および grunt-template-jasmine-requirejs を使用しています。

これは私のうなり声の設定です

    jasmine : {
        src : 'lib/**/*.js',
        options : {
            vendor: [
                'test/vendor/Sinon/sinon-1.14.1.js',
                'test/vendor/jasmine-jquery-master/vendor/jquery/jquery.js',
                'test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js'
            ],
            specs: 'test/spec/**/*.js',
            helpers: 'test/helpers/**/*.js',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
                requireConfigFile: 'lib/js/main.js',
                requireConfig: {
                    baseUrl: './lib/js/',
                    paths: {
                        'app': 'app',
                        'router': 'router',
                        'text': './text-master/text',
                    }
                }
            }
        }
    },

これを間違って設定したのでしょうか、それとも単に jasmine-jquery をヘッドレスで実行できないのでしょうか?

ありがとう

4

1 に答える 1

1

私は同じ問題に遭遇しました。karma.conf.jsファイルに別の順序でフレームワークを含めることで修正しました。

違う:

frameworks: ['phantomjs-shim', 'jasmine', 'jasmine-jquery']

正しい:

frameworks: ['phantomjs-shim', 'jasmine-jquery', 'jasmine']
于 2016-06-01T18:26:27.830 に答える