@36node/jest-runner-newman 中文文档教程
Jest Runner Newman
从 https://github.com/fixate/jest-runner-newman 分叉
目录
Purpose
使用 Newman 和 Jest 轻松地为您的 Postman 集合运行自动化测试。
Install
$ npm install -D jest-runner-newman newman
# jest.newman.js
module.exports = {
displayName: 'newman',
testMatch: ['<rootDir>/path/to/tests/**.test.js'],
runner: 'jest-runner-newman',
}
npx jest -c jest.newman.js
Running tests
jest-runner-newman
在 Node 子进程中运行 Newman 测试。 此外 通过 newman
模块运行 Newman 测试,每个测试都需要发送 parent 处理测试运行的结果。 为了使这更容易, jest-runner-newman
导出一个单独的模块来专门处理:
# my-collection.test.js
const {handleResult} = require('jest-runner-newman/handle-result')
const newman = require('newman');
module.exports = newman.run({
collection: `[collection-url]`,
environment: `[environment-url]`,
reporters: ['cli'],
// any other newman configs
}, (err, result) => {
handleResult(err, result);
// anything else you want
})
License
MIT
Jest Runner Newman
Fork from https://github.com/fixate/jest-runner-newman
Table of Contents
Purpose
Easily run automated tests for your Postman collections using Newman and Jest.
Install
$ npm install -D jest-runner-newman newman
# jest.newman.js
module.exports = {
displayName: 'newman',
testMatch: ['<rootDir>/path/to/tests/**.test.js'],
runner: 'jest-runner-newman',
}
npx jest -c jest.newman.js
Running tests
jest-runner-newman
runs Newman tests in Node child processes. In addition to running a Newman test via the newman
module, each test needs to send the parent process the result of the test run. To make this easier, jest-runner-newman
exports a separate module to specifically handle that:
# my-collection.test.js
const {handleResult} = require('jest-runner-newman/handle-result')
const newman = require('newman');
module.exports = newman.run({
collection: `[collection-url]`,
environment: `[environment-url]`,
reporters: ['cli'],
// any other newman configs
}, (err, result) => {
handleResult(err, result);
// anything else you want
})
License
MIT