草庐IT

gulp-jasmine

全部标签

javascript - Jasmine + AngularJS : How to test $rootScope. $broadcast 被调用参数?

我正在尝试编写一个单元测试来验证是否调用了$rootScope.$broadcast('myApiPlay',{action:'play'});。这是myapi.jsangular.module('myApp').factory('MyApi',function($rootScope){varapi={};api.play=function(){$rootScope.$broadcast('myApiPlay',{action:'play'});}returnapi;});这是我的单元测试:describe('Service:MyApi',function(){//loadtheser

javascript - 使用 Karma (Jasmine) 测试 AngularJS 工厂

我正在努力使用Karma+Jasmine测试AngularJS工厂。我无法将我的工厂注入(inject)OfficerValidationService变量。我做错了什么?注意:文件加载正确工厂:'usestrict';angular.module('darthvader').factory('OfficerValidationService',[function(){varOfficerValidationService={};OfficerValidationService.something=function(){returntrue;};returnOfficerValidat

javascript - 浏览器同步(在 gulp 下)不刷新浏览器

我的配置做了它应该做的一切,但它从不刷新浏览器。一旦我手动刷新它,就会有变化。我正在连接到默认的localhost:3000。任何想法为什么会这样或如何调试它?gulpfile.js:vargulp=require('gulp');varsass=require('gulp-sass');varsourcemaps=require('gulp-sourcemaps');varbrowserSync=require('browser-sync');gulp.task('html',function(){browserSync.reload();});gulp.task('sass',fu

javascript - Gulp.js 以特定顺序阻塞运行任务

使用gulp.js我有三个任务(uglify、buildHTML、rmRevManifest)我想作为父构建任务的一部分运行。我的代码有效,除了它并行运行任务(即不保留顺序)。我怎样才能让任务阻塞并且在上一个完成之前不运行下一个?即现在执行顺序返回为:[11:50:17]gulp-notify:[Gulpnotification]Deleted'rev-manifest.json'.[11:50:17]gulp-notify:[Gulpnotification]Created'build/index.html'.[11:50:17]gulp-notify:[Gulpnotificati

javascript - 如果满足条件,停止 Gulp 任务

我正在努力做到这一点,如果未指定--theme标志,它会停止gulp任务并想知道以DRY方式完成它的最佳方法。如果未指定--theme,我希望每个单独的任务都停止,如果不满足,我也希望默认任务停止。到目前为止,我已经尝试了一些没有运气的事情。谢谢,gulp.task('test',function(){if(typeof(args.theme)=='undefined'||args.theme===true){console.log(msg.noTheme);return;//endtask}//runrestoftask...});gulp.task('test-2',functio

javascript - Jasmine Node 完成未定义

一直在尝试简单的异步测试。安装jasmine-nodenpminstall-gjasmine-node然后编写一个简单的模块并测试。简单的模块。//weather.jsexports.get=function(city,callback){callback(city);};和一个测试套件。//weather-spec.jsvarlist=require("../modules/weather");describe("WeatherForecast",function(data){it('shouldgetweatherforLondon,UK',function(){list.get(

javascript - Gulp.js,保存文件时观察任务运行两次

鉴于我的gulpfile.js中的以下代码,每次我保存或更改文件时,任务都会运行两次而不是一次,这是为什么?我只希望它运行一次。vargulp=require('gulp');gulp.task('default',function(){gulp.watch('server/**/*.js',function(){console.log('ThisrunstwiceeverytimeIchange/saveajavascriptfilelocatedatserver/**/*.js');});});我对grunt和名为grunt-contrib-watch的插件也有同样的经历。

javascript - gulp-usemin 可以接受多个文件吗?

我有一个关于usemin的问题,我不确定它是否是一个错误。我的应用程序结构很简单:-root|-gulpfile.js|-app||-index.html||-about.html||-contact.html||-js||-a.js||-b.js||-c.js||-d.js||-e.js||-dist我的每个html文件中都有一个useminblock来包含所有脚本,例如:当我运行以下任务时:gulp.task('usemin'.function(){gulp.src('app/*.html').pipe(usemin({assetDir:'app/**/'})).pipe(dest

javascript - 在 Node.js 中使用 Jasmine 测试子 process.send

我有一个Node.js应用程序,它有一个main-process.js和一个child-process.js。main-process.js看起来像这样:varchildProcess=require('child_process');varjob=childProcess.spawn('node',["child-process.js"],{detached=true,stdio:['ipc']});我的child-process.js执行一些任务并通知父进程它的状态,它使用:exports.init=function(){//someprocessinghereprocess.se

javascript - $rootScope.digest 没有完成 Jasmine 中的 promise

我们目前正在尝试测试我们的Angular服务,它使用promise将值返回给Controller。问题是我们附加到.then的函数不会在Jasmine中被调用。我们发现在返回promise后将$rootScope.digest()添加到函数中允许调用同步promise,但它仍然不适用于异步promises。目前的代码是beforeEach(inject(function(Service,$rootScope){service=Service;root=$rootScope;}));it('getsalltheavailableproducts',function(done){servi