草庐IT

gulp-jasmine

全部标签

javascript - 是否可以在一个函数中定义一个 Jasmine 规范并且仍然有 beforeEach 应用于它?

我有很多几乎相同的测试。为了DRY和可扫描性,我想将测试抽象为一个函数,然后使用一些参数调用该函数。然后该函数将调用它并将规范添加到套件中。它似乎可以工作,除了规范不会以与其他规范相同的方式运行,并且beforeEach不会在公共(public)函数中定义的规范之前被调用。define(['modules/MyModule','jasmine/jasmine'],function(MyModule){describe('myModule',function(){functioncommonTests(params){it('shouldpassthistestOK',function(

javascript - 让 Jasmine 在服务器端运行

我正在尝试开始使用Node.JS在服务器端测试JavaScript我正在使用grunt,和grunt-jasmine-node,但我无法让它运行我的测试。它只是记录PSC:\Development\NET\Source\jsn>gruntRunning"jasmine_node"taskundefinedFinishedin0.001seconds0tests,0assertions,0failuresDone,withouterrors.这是我的Gruntfile.jsmodule.exports=function(grunt){grunt.initConfig({pkg:grunt

javascript - jquery-jasmine - 夹具无法加载

我正在尝试加载一些固定装置以进行测试。至此我已经准备好了一个json文件。我确实设置了应该加载特定文件的beforeEach函数,但出现错误:Error:Fixturecouldnotbeloaded:tests/license_filter/license_test_data.json(status:error,message:undefined)部分测试函数:beforeEach(function(){jasmine.getFixtures().fixturesPath='tests/license_filter';loadFixtures('license_test_data.j

javascript - 如何使用 Gulp 和 gulp-data 从单个 jade 模板生成多个 html 文件

我正在使用Gulp创建一个静态站点生成器.我想知道如何将每条数据(JSON)通过管道传输到一个jade模板中以生成多个html文件。这是gulp的"template"任务:gulp.task('templates',function(){'usestrict';varmyData=JSON.parse(fs.readFileSync('./_assets/data/content.json'));varmyPages=myData.pages;varmyPosts=myData.posts;gulp.src('./_assets/templates/index.jade').pipe(

javascript - Jasmine Controller 测试,预计 spy 已被调用

我在AngularJSController中定义了一个方法,该方法在初始化时调用。我想使用Jasmine("jasmine-core":"^2.3.4","karma":"^0.12.37")测试它。我遵循了Internet上的一些教程和StackOverflow问题,但找不到正确的答案。请看一下这段代码:ControllerusersAddUserController:(function(){'usestrict';angular.module('app.users.addUser').controller('usersAddUserController',['$scope','us

javascript - TypeScript、React 和 Gulp.js - 定义 React

我正在尝试创建一个工作流程,我可以在其中使用TypeScript编写React模块并通过Gulp.js自动编译为JavaScript。我正在使用TypeScript1.6.2、gulp-react和gulp-typescript。我的.tsx文件现在看起来像这样:///importReact=__React;interfaceHelloWorldProps{name:string;}varHelloMessage=React.createClass({render:function(){returnHello{this.props.name};}});React.render(,doc

javascript - 如何在 Gulp 4 中使用异步/等待?

我正在尝试做这样的事情:gulp.task("test",async()=>{returngulp.src("**/*.scss").pipe(print((filePath)=>`File:${filePath}`));});(打印为gulp-print)但它给出了以下内容:[22:08:43]Starting'test'...[22:08:43]Finished'test'after12ms[22:08:43]File:src\app\styles\app.scss[22:08:43]File:src\app\styles\test.scss即它在打印消息之前完成。我正在使用Gul

javascript - Gulp 在 Windows 上运行失败 |错误消息 : Microsoft JScript compilation error, 无效字符

我在我的Windows7本地机器上安装了Node.js如下链接所示:install-node-js-npm-windows之后我通过命令行通过这个命令安装了Gulp.js:npminstall-ggulp然后我将此路径添加到环境变量区域:C:\Users\Majid\AppData\Roaming\npm\node_modules\gulp\bin现在,当我尝试通过此命令运行gulp时:gulp我得到了这个错误:WindowsScriptHostLine:1Char:1Error:InvalidcharacterCode:800A03F6Source:MicrosoftJScriptc

javascript - AngularJs Jasmine 单元测试中的 $httpBackend

我无法让我的单元测试正常工作。我有一个开始为空的$scope数组,但应该用$http.get()填充。在真实环境中,数组中大约有15个左右的对象,但对于我的单元测试,我只抓取了2个。对于单元测试,我有:expect($scope.stuff.length).toBe(2);但jasmine的错误是:Expected0tobe2.这是我的controller.js:$scope.stuff=[];$scope.getStuff=function(){varurl=site.root+'api/stuff';$http.get(url).success(function(data){$sc

javascript - AngularJS Jasmine isolateScope() 返回未定义

我希望从我的help-button指令中的隔离范围中得到一些东西。it('shouldcontainproperscope,dependingonattributes',function(){varel=compile('')(scope);scope.$digest();console.log("el:"+el);console.log('Isolatedscope:'+el.isolateScope());..});--在每次测试之前beforeEach(inject(function($compile,$rootScope,$injector){compile=$compile;