jenkinsnightwatch

Nightwatch globals variable can't get on jenkins


Why the Nightwatch globals variable can't get on Jenkins? I added below in the nightwatch.js

"globals_path": "global.js"

And the test like this

module.exports = {
    "@tags": ["jenkins"],
    "Test on jenkins": browser => {
        let TEST_ONE = browser.globals.TEST_ONE;
        console.log(TEST_ONE);
        console.log(browser.globals);
    }
}

This is my globlas.js

module.exports = {
  TEST_ONE: "Hellow world"
};

When I run it in local it works well But it can't get the globals variable on Jenkins The console on the Jenkins

{
  abortOnAssertionFailure: true,
  waitForConditionPollInterval: 500,
  waitForConditionTimeout: 5000,
  throwOnMultipleElementsReturned: false,
  suppressWarningsOnMultipleElementsReturned: false,
  asyncHookTimeout: 10000,
  unitTestsTimeout: 2000,
  customReporterCallbackTimeout: 20000,
  retryAssertionTimeout: 5000,
  reporter: [Function: reporter]
}

The console on my local

{
  abortOnAssertionFailure: true,
  waitForConditionPollInterval: 500,
  waitForConditionTimeout: 5000,
  throwOnMultipleElementsReturned: false,
  suppressWarningsOnMultipleElementsReturned: false,
  asyncHookTimeout: 10000,
  unitTestsTimeout: 2000,
  customReporterCallbackTimeout: 20000,
  retryAssertionTimeout: 1000,
  reporter: [Function],
  TEST_ONE: 'Hellow world',
}```

Solution

  • I got the answer Just add this in the Jenkins shell #!/bin/sh -l