【问题标题】:newman: exportGlobals option within newman.run does not take the path specifiednewman:newman.run 中的 exportGlobals 选项不采用指定的路径
【发布时间】:2019-11-06 18:18:36
【问题描述】:

我正在尝试在我的 test1.js 中使用它:

const newman = require('newman'); // require newman in your project

// call newman.run to pass `options` object and wait for callback
newman.run({
  collection: require('./postman/poc_collection.json')
  environment: require('./postman/poc_env.json'),
  exportGlobals: require('./postman/poc_globals.json'),
  reporters: 'cli'
}, function (err) {
  if (err) { throw err; }
  console.log('collection run complete!');
});

运行完成后,将生成文件 newman-globals-2019-01-11-14-39-00-154-0.json 而不是使用 poc_globals.json 上面指定的文件。

newman 命令行中的 --export-globals 选项可以正常工作。

我错过了什么?

谢谢, 拉姆亚

【问题讨论】:

  • 您从哪里获得该属性名称?

标签: postman newman


【解决方案1】:

在设置全局文件的路径时不应使用 require()。试试:

exportGlobals: './postman/poc_globals.json',

但是,如果您希望脚本从全局文件加载变量,则需要使用它。

globals: require('./postman/poc_globals.json'),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-22
    • 2020-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多