0

为什么 Nightwatch 全局变量无法在 Jenkins 上运行?我在下面添加了nightwatch.js

"globals_path": "global.js"

像这样的测试

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

这是我的globlas.js

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

当我在本地运行它时它运行良好但它无法在 Jenkins 上获取全局变量 Jenkins 上的控制台

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

我本地的控制台

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

1 回答 1

0

我得到了答案只需在 Jenkins shell 中添加这个 #!/bin/sh -l

于 2020-01-16T14:33:53.340 回答