chai: Using Mocha framework with Appium for automation, I am also using chai should for assertions, but when they fail mocha waits for the time out and does not throw the assertion error
Sample code:
File 1 where should is being called:
var wd = require("wd");
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var should = chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
exports.should = should;
File 2 where I am using a should assertion:
'use strict';
require( 'colors' );
require( '../../helpers/setup' );
var alerts = require( '../../helpers/alerts' );
var assert = require( 'assert' );
//var expect = require( 'expect' );
var caps = require( '../../helpers/caps' );
var config = require( '../../helpers/Config' );
var commons = require( '../../helpers/Commons' );
var elements = require( '../../helpers/elements' );
var login = require( '../../helpers/loginTable' );
var Store = require( '../../helpers/Store' );
var driver = config.driver;
var truckOption;
var clockInOption;
var userRole;
var userName;
var name;
var permissionGranted;
var newJob;
describe( 'Start login Process'.green, function() {
it( 'should login'.green, function( done ) {
config.loginTest = true;
return driver
.elementByName( elements.loginScreen.client_account )
.isDisplayed().should.eventually.be.true
.elementByName( elements.loginScreen.user_name )
.isDisplayed().should.eventually.be.true
.elementByName( elements.loginScreen.password )
.isDisplayed().should.eventually.be.true
.elementByName( elements.loginScreen.login_button )
.isDisplayed().should.eventually.be.true
.elementByName( elements.loginScreen.accept_terms )
.isDisplayed().should.eventually.be.true
.elementByName( elements.loginScreen.client_account
So lets say 1st element is not displayed or returns false, should sees that and does not move on with the test, but at the same time does not throw the error why it failed or didnt move on
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (9 by maintainers)
@keithamus @lucasfcosta I’d love your guys opinion on this one. Seems like a tricky issue.
Here are some tests with the latest versions of node, mocha, chai, chai-as-promised, and bluebird.
Note that the only combination that doesn’t produce a useful stack trace is native promises + chai-as-promised (regardless of
chai.config.includeStacksetting).Results:
Let me work on that.