mocha

Error “step is not defind” using Mocha Test and what is mean by “Then simply run mocha with --require mocha-steps” in tutorial

丶灬走出姿态 提交于 2020-01-11 13:07:13
问题 `describe('my smoke test', function() { step('login', function() { vdriver.wait(until.elementLocated(By.name('UserName'))).sendKeys("aqdjska@gmail.org"); driver.wait(until.elementLocated(By.id("mat-input-3"))).sendKeys("cool123"); driver.sleep(2000); driver.wait(until.elementLocated(By.css(".mat-progress-spinner-light > div"))).click(); }); step('Open Apps', function() { driver.wait(until.elementLocated(By.xpath("//span[contains(text(), 'Apps')]"))).click(); driver.wait(until.elementLocated

Run project exsiting HTML file after code coverage finish in grunt

假装没事ソ 提交于 2020-01-07 07:43:51
问题 I've node app which use grunt to generate code coverage report this report is located under and I was able to run it manually myAPP -coverage -index.html I want that when the task of coverage will finish and the report is generated to run this index.html in the browser,how should I do that? I found this https://www.npmjs.com/package/grunt-run but its not working I try many ways grunt.initConfig({ run: { commands: { exec: '/coverage/lcov-report/index.html', } } }); or grunt.initConfig({ run: {

How to test for a propety of a class after promise resolution with mocha and chai

半腔热情 提交于 2020-01-07 06:25:53
问题 I am trying out a bit of unit testing with Mocha + Chai as promised 'use strict'; var chai = require('chai').use(require('chai-as-promised')) var should = chai.should(); describe('Testing how promises work', () => { it("should work right", function(){ class SomeClass { constructor() { this.x = 0; } getSomething(inputVal) { let self = this; return new Promise((resolve, reject) => { setTimeout(function(){ if(inputVal){ self.x = 1; resolve(); } else{ self.x = -1; reject(); } }, 10); }); } } var

How to get a sinon stub to call another function on nth call

天涯浪子 提交于 2020-01-07 05:46:27
问题 I want to use a sinon stub to asynchronously test an event emitter. I want the stub to call a callback after it is called. I thought stub.yields was what I want but not. Is there a neat way to do this? it('asynchronously emits finish after logging is complete', function(done){ const EE = require('events'); const testEmitter = new EE(); var cb = sinon.stub(); cb.calls(completed); // no such method but this is what I need testEmitter.on('finish', cb.bind(null)); testEmitter.emit('finish');

How to successfully ignore specs with mocha?

半腔热情 提交于 2020-01-07 01:18:40
问题 I use mocha, and I use "skip" and "only" to run specific specs and tests. But it seems that each time mocha applies these only on the tests. so if I have this code: var expect = require('expect.js'); var logger = require('log4js').getLogger('TestDemo'); describe('test', function(){ logger.info('this will appear'); it('should not appear', function(){ expect(1+1).to.be(5); }); }); describe.only('should run', function(){ logger.info('this will appear to'); it('should appear', function(){ expect

How to successfully ignore specs with mocha?

﹥>﹥吖頭↗ 提交于 2020-01-07 01:18:00
问题 I use mocha, and I use "skip" and "only" to run specific specs and tests. But it seems that each time mocha applies these only on the tests. so if I have this code: var expect = require('expect.js'); var logger = require('log4js').getLogger('TestDemo'); describe('test', function(){ logger.info('this will appear'); it('should not appear', function(){ expect(1+1).to.be(5); }); }); describe.only('should run', function(){ logger.info('this will appear to'); it('should appear', function(){ expect

Mocha/Chai Tests using Mongoose Occasionally Fail on First Run

情到浓时终转凉″ 提交于 2020-01-06 20:21:19
问题 I have a series of Mocha/Chai tests that are set up as follows: var mongoTest = require('../mongoTest.js'); //Connect to test DB before tests and disconnect after before(function(done) { mongoTest.mongoConnect(done); }); after(function(done) { mongoose.disconnect(done); }) //Load Data Files var testData = require('../testData.js') var deviceAndLocationAnswers = testData.deviceAndLocationAnswers //Repeated Functions: var clearCollections = function(coll, callback) { mongoose.connection.db

Catch-22 recursive Node modules blowing up when using Mocha

人走茶凉 提交于 2020-01-06 15:06:27
问题 I've been working on a project that uses some custom Node.js modules. I've created a 'helpers' module that assists with loading some helper methods: /helpers/index.js: var mutability = require('./mutability'), cb = require('./cb'), build = require('./build'), userAgent = require('./userAgent'), is = require('./is'), query = require('./query'), config = require('./config'), _ = require('underscore') module.exports = _.extend({ cb: cb, build: build, userAgent: userAgent, is: is, query: query,

Catch-22 recursive Node modules blowing up when using Mocha

久未见 提交于 2020-01-06 15:03:21
问题 I've been working on a project that uses some custom Node.js modules. I've created a 'helpers' module that assists with loading some helper methods: /helpers/index.js: var mutability = require('./mutability'), cb = require('./cb'), build = require('./build'), userAgent = require('./userAgent'), is = require('./is'), query = require('./query'), config = require('./config'), _ = require('underscore') module.exports = _.extend({ cb: cb, build: build, userAgent: userAgent, is: is, query: query,

How to make nightmare forcefully timeout

跟風遠走 提交于 2020-01-06 08:21:09
问题 As the title implies I am trying to make my script timeout forcefully, specifically if a condition (that returns done() ) isn't met. Here is some code: import * as Nightmare from "nightmare"; describe("Login Page", function() { this.timeout("30s"); let nightmare = null; beforeEach(() => { nightmare = new Nightmare({ show: true }); }); let pageUrl; describe("give correct details", () => { it("should log-in, check for current page url", done => { nightmare .goto(www.example.com/log-in) .wait