0

I am a JS and Mocha newbie. This is my simplified source file.

$browser.get(LOGIN_URL)
  .then(() => Promise.all([
    populateInputById('signin-email', 'email', ACCOUNT_EMAIL),
    populateInputById('signin-password', 'password', ACCOUNT_PASSWORD),
  ])).
then(() => {
  console.log('Success');
});

The $browser object is a global object, and is used by our system. I am supposed to write unit test for this function. That means that I need to be able to initialise this object.

I have read through mocha docs, and SO posts like this joining tests from multiple files with mocha.js. But how do I initialise the $browser object?

My unit test file is as follows:

var assert = require('assert');

describe('Sample test', function() {
  it('login test', function() {
      // I need to initialise $browser here.
  })

})
halfer
  • 19,824
  • 17
  • 99
  • 186
Kartik
  • 2,541
  • 2
  • 37
  • 59
  • 1
    Can you show your current test file? With its `import`s, `require`s and all? – acdcjunior Apr 09 '18 at 18:29
  • Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened. – halfer Apr 21 '18 at 12:02

0 Answers0