Nightwatch 全局变量无法进入詹金斯
Nightwatch globals variable can't get on jenkins
为什么 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',
}```
我得到了答案
只需将其添加到 Jenkins shell
#!/bin/sh -l
为什么 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',
}```
我得到了答案
只需将其添加到 Jenkins shell
#!/bin/sh -l