2

このgithub issueから取られた、単純なモックの例を設定しようとしています:

'use strict';

var expect = chai.expect;

var app = angular.module('plunker', [])
    .factory('car', function(engine) {
        return {
            drive : function() {
                return 'Driving: ' + engine.speed();
            }
        }
    })
    .value('engine', {
        speed : function() {
            return 'fast';
        }
    });

describe('Testing a car', function() {
    var testEngine;

    beforeEach(function(){
        testEngine = {};
        angular.module('test', ['plunker']).value('engine', testEngine);
        module('test');
    });

    it('should drive slow with a slow engine', inject(function(car) {
        testEngine.speed = function() {
            return 'slow';
        };
        expect(car.drive()).to.equal('Driving: slow');
    }));
});

ただし、Testacular (Mocha を使用) で実行しようとすると、次のエラーが発生します。

info (watcher): Changed file "/path/to/testMock.js".
PhantomJS 1.7 (Mac) Testing a car "before each" hook FAILED
    TypeError: 'undefined' is not an object (evaluating 'currentSpec.queue.running')
        at isSpecRunning (/path/to/angular-mocks.js:1626)
        at /path/to/angular-mocks.js:1648
        at /path/to/testMock.js:25
PhantomJS 1.7 (Mac): Executed 29 of 41 (1 FAILED) (0.215 secs / NaN secs)

私は何を間違っていますか?

4

0 に答える 0