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
See original GitHub issueSample 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
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
mochajs/mocha - Gitter
Anyone know how to throw an assertion error when using driver.waitForElementByName( element, 180000 ); I need it to wait the 180000 and if...
Read more >Mocha Assertions: What They Are and How to Use Them
There are different things we can verify using assertions. In this post, you'll learn about assertions in Mocha and how to use them....
Read more >node.js - Verify that an exception is thrown using Mocha / Chai ...
The problem with this approach is that (await fails()).should.throw(Error) doesn't make sense. await resolves a Promise .
Read more >Errors on previously running Javascript/Mocha iOS Automation
“before each” hook for “Onboarding Login Test”: TypeError: driver.init is not a function at Context.beforeEach (login.test. · “after each” hook ...
Read more >Selenium Wait Tutorial with All Strategies!
If we do not pay attention to Selenium Webdriver Wait in our projects, this will generally lead to non-reliable, intermittent, slow, and non- ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.includeStack
setting).Results:
Let me work on that.