我的文件夹结构如下:
Root
|- Scripts
|- ViewScripts
|- Feature_1
|- feature_1.js
|- Jasmine
|- Helpers
|- jasmine.js
|- Spy.js
|- mock-ajax.js
|- jasmine-jquery.js
|- Tests
|- Feature_1_Tests
|- feature_1.tests.js
|- chutzpah.json
|- gulpfile.js
|- package.json
chutzpah.json的内容是:
{ "Framework": "jasmine", "References": [
{ "Path": "Scripts/jquery-1.10.2.js" },
{ "Path": "Scripts/Jasmine/Helpers/jasmine.js" },
{ "Path": "Scripts/Jasmine/Helpers/jasmine-html.js" },
{ "Path": "Scripts/Jasmine/Helpers/boot.js" },
{ "Path": "Scripts/Jasmine/Helpers/mock-ajax.js" },
{ "Path": "Scripts/Jasmine/Helpers/Spy.js" },
{ "Path": "Scripts/Jasmine/Helpers/jasmine-jquery.js" } ] }
gulpfile.js的内容是:
const gulp = require('gulp');
const jasmine = require('gulp-jasmine');
gulp.task('tests', () =>
gulp
.src('Tests/**/*.tests.js')
.pipe(jasmine())
);
package.json文件的内容是:
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "",
"scripts": {
"test": "gulp tests"
},
"author": "Jai Kumar",
"license": "ISC",
"devDependencies": {
"gulp": "^4.0.0",
"gulp-jasmine": "^4.0.0"
}
}
当我从cmd进行gulp 测试时:
- 所有测试用例都失败。
- 我看到每个测试用例的以下错误 - ReferenceError : functionNameWhichIHaveSpyOn未定义
- 在所有测试用例运行并失败后,cmd底部的消息是插件“gulp-jasmine”中的错误
但是,当我在 Visual Studio 测试资源管理器中使用 chutzpah 运行相同的测试用例时,所有测试用例都通过了。
请在这个问题上帮助我。提前致谢。