草庐IT

Grunt-mocha-test

全部标签

ruby-on-rails - 如何在测试环境运行Rails控制台并加载test_helper.rb?

背景:我在使用Thoughtbot的“工厂女孩”gem时遇到了一些问题,该gem用于创建要在单元测试和其他测试中使用的对象。我想转到控制台并运行不同的FactoryGirl调用以检查发生了什么。例如,我想去那里做...>>Factory(:user).inspect我知道您可以在不同的环境中运行控制台...$脚本/控制台RAILS_ENV=test但是当我这样做时,工厂类不可用。看起来好像test_helper.rb没有加载。我尝试了各种require调用,包括一个带有到test_helper.rb的绝对路径的调用,但它们的失败与此类似:$script/consoleRAILS_ENV

ruby-on-rails - 什么是 rake db :test:prepare actually do?

我正在观看Rails教程视频,但我无法弄清楚db:test:prepare命令的实际作用。有人可以提供解释吗? 最佳答案 Therakedb:migrateaboverunsanypendingmigrationsonthedevelopmentenvironmentandupdatesdb/schema.rb.Therakedb:test:loadrecreatesthetestdatabasefromthecurrentdb/schema.rb.Onsubsequentattempts,itisagoodideatofirstr

javascript - Node.js - 为什么在使用 mocha 和 zombie 进行测试时会出现泄漏?

我试图让zombie与mocha一起工作,但除非我使用mocha--ignore-leaks命令选项,否则我的测试总是失败并显示错误:Error:globalleaksdetected:k,i,name,chars,char我的测试看起来与该线程中解释的完全一样:MochaandZombieJS我希望我可以在那里发布我的问题,但是作为一个新手,我不能对线程发表评论,只能提出一个新问题。你知道我为什么会出现这些泄漏吗?我正在使用mocha1.0.3和zombie1.0.0。 最佳答案 泄漏可能来自您自己的代码或您使用的node_mod

javascript - grunt-typescript 不会在指定的 `dest` 中生成 js 文件

我有以下目录结构:root||_package.json|_Gruntfile.js||_javascripts/|_ts/file.ts在Gruntfile中我有这个://ProjectConfiggrunt.initConfig({pkg:grunt.file.readJSON('package.json'),typescript:{base:{src:['./javascripts/ts/*.ts'],dest:'./javascripts/'}}});我希望js文件位于javascripts/目录中。但是,当我运行grunttypescript时,它会创建这个奇怪的目录结构:r

javascript - chai 没有在 Karma-mocha 中定义

我正在使用mocha-phantomjs配置成功运行我的测试用例。现在我正在使用Karma启动器运行这些测试。但我遇到了问题Chaiisnotdefined。这是我的配置文件。module.exports=function(config){config.set({client:{mocha:{ui:'tdd'}},basePath:'',frameworks:['mocha'],files:['web/js/*.js','test/lib/*.js','node_modules/chai/chai.js'//addedthisonsuggestionoftheanswerinstack

javascript - 类型错误 : parsed is undefined on angularjs service unit test

我正在尝试对使用$http的服务进行单元测试。我正在使用Jasmine,但我一直收到此错误:TypeError:parsedisundefinedinangular.js(line13737)这是我的服务的样子:angular.module('myapp.services',[]).factory('inviteService',['$rootScope','$http',function($rootScope,$http){varinviteService={token:'',getInvite:function(callback,errorCallback){$http.get('

javascript - 使用依赖注入(inject)和 `done` 编写 Karma + Mocha 测试?

在既有依赖注入(inject)又完成的mocha中编写Karma单元测试的最优雅的方法是什么?依赖注入(inject):describe('cows',function(){it('fartsalot',inject(function(cow){//dostuff}))})完成:describe('cows',function(){it('fartsalot',function(done){//dostuff})})如果我想在我的单元测试中同时使用cow和done怎么办?现在,这就是我正在做的,但并不令人满意。beforeEach(inject(function(cow){this.c

javascript - 如何在 Grunt 中使用 stylelint?

我正在尝试替换grunt-scss-lint(因为它的Ruby依赖性和未安装gem时的静默失败)与stylelint.我遇到的问题是以下错误:$gruntLoading"Gruntfile.js"tasks...ERROR>>ReferenceError:Mapisnotdefined我认为这是因为stylelint(它是一个PostCSS插件,而不是一个Grunt插件)需要ES6。Here'sthecodethat'sthrowingtheMapisnotdefinederror.有什么方法可以让它工作,我可以只运行grunt而不是一些奇怪的解决方法likethis?

javascript - 如何在 mocha 中使用 should() 的 OR 条件

我想使用两个值进行比较,这样如果其中一个为真,那么我的测试应该通过。使用下面的代码只是比较第一个条件并且测试失败。if(typeoflng!=='undefined'){data.lng.should.equal(lng)||data.cityLng.should.equal(lng);我应该怎么做? 最佳答案 试试这个:if(typeoflng!=='undefined'){lng.should.be.equalOneOf(data.lng,data.cityLng);参见documentation.

javascript - 如何封装mocha `expect()`代码?

我正在尝试测试是否存在一些我希望在所有测试中都需要的api响应属性(status和data属性)。这是一个通用测试,它断言supertest中的所需属性expect()方法:it('shouldcreateawidget',done=>{letstatus=200;request(test_url).post('/api/widgets').set('Authorization',`Bearer${token}`).send({sku:my_widget_data.sku,name:my_widget_data.name,description:''}).expect(res=>{as