Home » Javascript » TypeError: test.describe is not a function when using nodejs, selenium and mocha

TypeError: test.describe is not a function when using nodejs, selenium and mocha

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am getting TypeError: test.describe is not a function when using ‘test’ with describe, it, before etc.

Using node, selenium and mocha to run tests.

Please find the code below:

Test that I am executing:

 var LoginObj = require('../pages/Login.js');
 var HomeObj = require('../pages/Home.js');
 var LoginData = require('../testdata/LoginData.json');
 var using = require('jasmine-data-provider');
 var basetest = require('../pages/BaseTest.js');
 var test = require('selenium-webdriver/testing')
 var driver = basetest.getDriver();

 test.describe('Checking  Login Functionality', function() {

 test.beforeEach(function(){
    driver.get('https://applicationurl.com');
    driver.manage().window().maximize();
    //driver.manage().timeouts().implicitlyWait(30000);

 });

 LoginData.forEach(function(data, username, password) {
 test.it('Login with: '+data.username+" and "+data.password, function() {

    //LoginObj.get();

    LoginObj.login(data.username, data.password, data.answer);

    assert.isTrue(HomeObj.isLogoutDisplays(),'Login successful, Passing 
     Test!')
     console.log('Login flag is: '+HomeObj.isLogoutDisplays()+', Failing 
     Test!');



   })

    });

   test.afterEach(function() {

        HomeObj.logout();


    }) 

 });
Answers: