A few months ago I had some Appium automation running successfully in Javascript using Mocha. I’ve moved over to a new laptop and app and replicated the same structure, but I’m receiving the below errors. Any help would be greatly appreciated!:
simon.g$ mocha ./login.test.js --timeout 1000000
2019-02-20T09:19:19.152Z DEBUG wdio-config: @wdio/sync not found, running tests asynchronous
(node:2338) UnhandledPromiseRejectionWarning: Error: Required option “capabilities” is missing
at validateConfig (/Users/simon.g/appium/node_modules/@wdio/config/build/utils.js:168:13)
at Object.remote (/Users/simon.g/appium/node_modules/webdriverio/build/index.js:28:45)
at Object. (/Users/simon.g/appium/login.test.js:6:21)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach ()
at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:576:10)
at Object. (/usr/local/lib/node_modules/mocha/bin/_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
at internal/main/run_main_module.js:21:11
(node:2338) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2338) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Login Test Suite
1) “before each” hook for "Onboarding Login Test"
2) “after each” hook for “Onboarding Login Test”
0 passing (9ms)
2 failing
-
“before each” hook for “Onboarding Login Test”:
TypeError: driver.init is not a function
at Context.beforeEach (login.test.js:37:16)
-
“after each” hook for “Onboarding Login Test”:
TypeError: driver.end is not a function
at Context.afterEach (login.test.js:43:16)
Here’s my code:
const wdio = require(‘webdriverio’);
const caps = require(’./helpers/desiredCapabilities’).options;
const driver = wdio.remote({
protocol: “http”,
host: “localhost”,
port: 4723,
path: “/wd/hub”,
desiredCapabilities: caps.desiredCapabilities
});
var chai = require(‘chai’);
var assert = require(‘chai’).assert;
//var expect = require(‘chai’).expect;
var chaiAsPromised = require(‘chai-as-promised’);
chai.use(chaiAsPromised);
chai.should();
var Switch = require(’./helpers/constants’);
beforeEach(async () => {
//console.log(“beforeEach”);
await driver.init();
});
afterEach(async () => {
//console.log(“afterEach”);
await driver.end();
});
describe(“Login Test Suite”, () => {
it(“Onboarding Login Test”, async () => {
await driver
.waitForEnabled(Switch.EnvContinue, 15000)
.element(Switch.EnvHeroku).click()
.element(Switch.EnvContinue).click()
.element(Switch.EnvConfirmPopupYes).click()
return driver.element(Switch.OnboardingSkip).isVisible().then(function (isOnboardingVisible) {
assert(isOnboardingVisible, “Onboarding is not visible”);
})
});
});