Running tests with Mocha/Appium

I am working on building some tests for our iOS application using Appium. We are building the tests with javascript as our language of choice, and are using Mocha as the testing framework. At this point, I am able to get my tests to run, and the automation will take place with not problem. Where I am stuck is that the done() method does not seem to be recognized when the automation is completed, and the test times out, thus failing every time. As far as I can tell I have the test set up correctly. Here is an example of my test. Any thoughts or help would be most appreciated.

 var browser = wd.promiseChainRemote('127.0.0.1', 4723);

 describe('Should run desired tests', function() {
    this.timeout(120000);

    var allPassed = true,
    browser = wd.promiseChainRemote('127.0.0.1', 4723);

    before(function() {
	return browser
	.init(desired)
	.setImplicitWaitTimeout(120000);
    });

    it('should login successfully', function (done) {
	// return logIn();
	return browser
		.elementByXPath(login).click()
		.elementByName("s").click()
		.elementByName("o").click()
		.elementByName("m").click()
		.elementByName("e").click()
		.elementByName("n").click()
		.elementByName("a").click()
		.elementByName("m").click()
		.elementByName("e").click()
		.elementByName("@").click()
		.elementByName("e").click()
		.elementByName("m").click()
		.elementByName("a").click()
		.elementByName("i").click()
		.elementByName("l").click()
		.elementByName(".").click()
		.elementByName("c").click()
		.elementByName("o").click()
		.elementByName("m").click()
		.elementByName(next).click()
		.elementByName(shift).click()
		.elementByName("P").click()
		.elementByName("a").click()
		.elementByName("s").click()
		.elementByName("s").click()
		.elementByName("w").click()
		.elementByName("o").click()
		.elementByName("r").click()
		.elementByName("d").click()
		.elementByName(more).click()
		.elementByName(signIn).click()
		done();
     });

});

Hey @sqorandy try using .nodeify(done) after your last .click().

It’s working for me.

Hey @vrunoa, thank you for your reply. I actually was able to get it to work by adding the done call within the last click like so, .click(done)

1 Like