Ser*_*gey 18 javascript backbone.js sinon
我正在尝试使用sinon.js测试骨干应用程序.但不幸的是我因为错误而无法使用间谍方法:
TypeError: 'undefined' is not a function (evaluating 'sinon.spy()')
Run Code Online (Sandbox Code Playgroud)
以下是重现错误的步骤:
cd test && bower install sinon<script src="bower_components/sinon/lib/sinon.js"></script>在test/spec/test.js中创建间谍:
describe('Give it some context', function () {
describe('maybe a bit more context here', function () {
it('should run here few assertions', function () {
var spy = sinon.spy();
spy.should.be.ok;
});
});
});
Run Code Online (Sandbox Code Playgroud)用grunt运行测试: grunt test
测试将失败并显示错误.
谁能帮忙找出问题所在?
Kam*_*zot 14
我将在这里留下sinon方便忘记加载的文件列表,如果它作为a <script>或with require.js(作为AMD模块)加载- 基本上除了node.js:
"sinon/lib/sinon.js",
"sinon/lib/sinon/spy.js",
"sinon/lib/sinon/call.js",
"sinon/lib/sinon/behavior.js",
"sinon/lib/sinon/stub.js",
"sinon/lib/sinon/mock.js",
"sinon/lib/sinon/collection.js",
"sinon/lib/sinon/assert.js",
"sinon/lib/sinon/sandbox.js",
"sinon/lib/sinon/test.js",
"sinon/lib/sinon/test_case.js",
"sinon/lib/sinon/match.js"
Run Code Online (Sandbox Code Playgroud)
随意跳过这些,但希望sinon以奇怪的方式失败.
Ser*_*gey 13
事实证明,应该通过包含lib/sinon文件夹中的脚本手动添加间谍,存根等功能.安装部分提到了这一事实.并且由于仅在Node.js环境中的核心sinon.js文件的代码,它是自动完成的.
| 归档时间: |
|
| 查看次数: |
9947 次 |
| 最近记录: |