Mocha抱怨说cb在运行自动生成器测试时不是一个函数

时间:2016-02-28 21:38:32

标签: mocha yeoman yeoman-generator

我构建了一个yeoman生成器,它从rest api中获取数据,并使用这些文件填充app dir中的html,css和js文件。我正在尝试学习如何构建相应的mocha测试,但在我的文件存在测试中继续遇到错误。

我通过"发电机负载"测试,但当我尝试" do文件存在"测试,我在控制台收到错误:

1)creates files creates expected files:
Uncaught TypeError: cb is not a function
at null.<anonymous> (node_modules/yeoman-generator/lib/base.js:400:5)
at Queue.<anonymous> (node_modules/grouped-queue/lib/queue.js:68:12)

我的测试如下

/*global describe, beforeEach, it*/
'use strict';

var path    = require('path');
var helpers = require('yeoman-generator').test;

describe("creates files", function(){
    beforeEach(function (done){
        helpers.testDirectory(path.join(__dirname, 'temp'), function(err){
            if(err){
                return done(err);
            }

            this.app = helpers.createGenerator('snow:app',['../../app']);

            done();
        }.bind(this));
    });

    it("creates expected files", function(done){
        helpers.mockPrompt(this.app,{
            hostname : "empasiegel1",
            username : "password",
            password : "password",
            solution : "testSnow"
        });

        this.app.run({}, function() {
            helpers.assertFile('package.json');
            done();
        });
    });
});

它可以与其余调用的异步性质有关吗?

0 个答案:

没有答案