简体   繁体   中英

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

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();


    }) 

 });

If you are using mocha you will not need this:

var test = require('selenium-webdriver/testing')

Just remove the 'test' from 'test.describe' and it will work.

So it should be:

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

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

 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM