newman:newman.run中的exportGlobals选项未采用指定的路径

时间:2019-01-11 15:01:55

标签: postman newman

我正在尝试在我的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选项可以正常工作。

我想念什么?

谢谢, 拉米亚

1 个答案:

答案 0 :(得分:0)

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

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

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

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