我有一个生成器函数,我正在尝试对其进行单元测试。我正在测试的函数也将生成器作为方法参数。
我可以运行mocha --harmony
,所以它运行测试但是,我已经在我的测试文件中放置了一个生成器函数,这将是我将传递给我正在测试的函数的函数,但是 mocha 抛出一个错误,说它不理解*
我的测试文件。
例如,
function mytestgenerator() * {
return "next gen"
}
describe('my app', function () {
describe('important method', function () {
it('should return -1', function () {
var result = sut(mytestgenerator);
})
})
})
/Users/jonathan/Projects/myapp/test/index_spec.js:9
function mytestgenerator() * {
^
SyntaxError: Unexpected token *