chai

UI Protractor Find & Click Select Box Based On Text Search

╄→гoц情女王★ 提交于 2019-12-13 19:19:46
问题 I am trying to find a way to search for the row that has the name X in it and then click on the checkbox in that row using UI Protractor. I have been very unsuccessful so far. If you see below, I want to search for testproxy and then click the checkbox associated with it. <div id="general_section"> <p> The following proxies are available to add to a cluster.</p> <div class="table-responsive"> <table id="proxies_table" class="table table-striped table-bordered"> <thead> <tr> <th><input type=

Mocha flow control after assertion fails

瘦欲@ 提交于 2019-12-13 17:34:14
问题 I think mocha stops running the current test case after assertion fails, like this it('test', function(done) { a.should.equal(b); //if a is not equal to be, won't go here //do something done(); } I need to continue doing something after assertion fails, I tried to use try...catch, but there is no "else" for catch, so if I do try { a.should.equal(b) } catch(e) { console.log(e) done(e) } finally { //do something done() } this will call done() twice, so I have to add a flag, var flag = true; try

Cypress.io: Anyway to test for specific scroll amount?

有些话、适合烂在心里 提交于 2019-12-13 15:22:02
问题 Wanted to know if there is some way to test for scroll amount, within a certain range with Cypress.io. More Specifically Starting from top of page, press button Page scrolls down to a certain height Test whether scroll height is correct within a certain range My attempt: The way I assume would be best is to test that would to test out, that a current div is not within the viewable area of phone screen. Then to scroll down so it does become viewable. cy.get('#angular-projects').should('not.be

Chai, Mocha: Identify should assertion

£可爱£侵袭症+ 提交于 2019-12-13 13:10:21
问题 I'm using mocha and chai as assertions. I have several assertions in my spec: Exp1.should.be.true Exp2.should.be.true Exp3.should.be.true If one of them fails mocha writes "expected false to be true". Is there a way to identify them? With expect I can do it: expect(Exp1, 'Exp1').to.be true Is something like this possible with should ? 回答1: Apparently should does not support custom error messages at the moment. You can create your own helper for setting the message: var chai = require('chai'),

Cucumber + Protractor - timed out error while executing the steps

旧巷老猫 提交于 2019-12-13 08:41:54
问题 I am using cucumber and protractor to write behavioural driven tests.My scenarios and all the steps will pass but at the end it will show timed out error. The homepage will get loaded for the first step and later it will not perform any steps described in the steps definition file. Once the page is loaded it should click on the tabs. I have mentioned these steps in step definition file.But these steps are not executed and it will show all the steps passed in the console. I followed this link

Write tests for an angular REST app

三世轮回 提交于 2019-12-13 00:54:56
问题 I've been clueless so far. Say I have this very simple app module: var app = angular.module('myApp', []); app.service('searchService', ['$http', function($http){ var baseURL="https://someonehost.com/product/search&query="; return { search: function(query){ return $http.get(baseURL+query); } }; }]); app.controller('mainCtrl', ['$scope','searchService',function($scope, searchService) { searchService.search($scope.searchWords).success(function(data) { $scope.responseData=data; }); }]); It works

Why am I getting this Angular-Mock error and Mocha test is not running

人盡茶涼 提交于 2019-12-13 00:49:46
问题 I'm getting the exact error as found here : (window.beforeEach || window.setup) is not a function. However the fix did not work , the author of the tutorial series here even mentioned the same fix. Here is the Tuts+ author's fix: Which is simply to place the angular-mock script tag after the Mochai and Chai scripts. Which I did so below: test/index.html <!DOCTYPE html> <html lang="en"> <head> <title>Mocha Spec Runner</title> <meta charset="utf-8"> <meta name="viewport" content="width=device

Access for global variables JavaScript unit testing

风格不统一 提交于 2019-12-12 17:14:59
问题 Hello I am new JavaScript unit testing and I'm using Mocha.js and Chai.js What I want to do is simply figure out how to check the value of a global variable in a seperate js file. Here is my code Here is the main.js file (code to be tested) Just has the variable I want to test against. //main.js var foo = 9; Here is my test file var assert = require("assert") var expect = require('chai').expect var fs = require("fs") var vm = require("vm") function include(path){ var code = fs.readFileSync

How to spy on an imported function using Sinon?

≡放荡痞女 提交于 2019-12-12 13:34:14
问题 Let's say we want to test that a specific function is called by another function using Sinon. fancyModule.js export const fancyFunc = () => { console.log('fancyFunc') } export default const fancyDefault = () => { console.log('fancyDefault') fancyFunc() } fancyModule.test.js import sinon from 'sinon' import fancyDefault, { fancyFunc } from '../fancyModule' describe('fancyModule', () => { it('calls fancyFunc', () => { const spy = sinon.spy(fancyFunc) fancyDefault() expect(spy.called).to.be.true

Chai-As-Promised is eating assertion errors

爱⌒轻易说出口 提交于 2019-12-12 10:34:44
问题 I'm using chai-as-promised + mocha for writing some selenium-webdriver tests. Since webdriver extensively uses promises , I imagined it would be better if I used chai-as-promised for those type of tests. The problem is that when the tests fail, the error is not being caught properly by mocha, and it just fails without outputting anything. Sample code: it 'tests log', (next) -> log = @client.findElement(By.css("...")) Q.all([ expect(log.getText()).to.eventually.equal("My Text") expect(log