newman
newman copied to clipboard
newman doesn't execute test scripts declared in `script.src` field
-
Newman Version (can be found via
newman -v
):4.5.1
-
OS details (type, version, and architecture):
Official Docker image, alpine-based (postman/newman:4.5.1-alpine)
-
Are you using Newman as a library, or via the CLI?
CLI
-
Did you encounter this recently, or has this bug always been there:
This is the very first time I try to execute this
-
Expected behaviour: Execute test scripts in external files, as well as embedded ones
-
Command / script used to run Newman:
docker run --rm -t -i -v $PWD:/etc/newman postman/newman:4.5.1-alpine run collection.json
- Sample collection, and auxiliary files (minus the sensitive details):
-
collection.json
:
{
"info": {
"name": "Examples",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "HTTP GET with embedded test script",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Embedded: status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "https://postman-echo.com/get",
"protocol": "https",
"host": [
"postman-echo",
"com"
],
"path": [
"get"
]
}
},
"response": []
},
{
"name": "HTTP GET with linked test script",
"event": [
{
"listen": "test",
"script": {
"src": "./test_script.js",
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "https://postman-echo.com/get",
"protocol": "https",
"host": [
"postman-echo",
"com"
],
"path": [
"get"
]
}
},
"response": []
}
]
}
-
test_script.js
:
pm.test("Linked: status code is 200", function () {
pm.response.to.have.status(200);
});
- Screenshots (if applicable):
As you can see, no assertion is executed for call
HTTP GET with linked test script
, and the total count is 1:
Examples
→ HTTP GET with embedded test script
GET https://postman-echo.com/get [200 OK, 604B, 644ms]
✓ Embedded: status code is 200
→ HTTP GET with linked test script
GET https://postman-echo.com/get [200 OK, 698B, 116ms]
┌─────────────────────────┬─────────────────────┬────────────────────┐
│ │ executed │ failed │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ requests │ 2 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ test-scripts │ 2 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ prerequest-scripts │ 0 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ assertions │ 1 │ 0 │
├─────────────────────────┴─────────────────────┴────────────────────┤
│ total run duration: 862ms │
├────────────────────────────────────────────────────────────────────┤
│ total data received: 544B (approx) │
├────────────────────────────────────────────────────────────────────┤
│ average response time: 380ms [min: 116ms, max: 644ms, s.d.: 264ms] │
└────────────────────────────────────────────────────────────────────┘
Any update on if this will be addressed? I see src
in the v2.1 schema, but it doesn't seem to be implemented.
I would love love love to be able to edit postman scripts outside of the postman app, as my postman collections/test/environments live within a github repo alongside other source-controlled code.
I find it hard to believe the only way I can update my Postman scripts is editing from within Postman just so I can export it in order to overwrite the postman_collection.json
file that already exists for my tests. It is a real killer of my workflow and probably the only thing I dont like about Postman
Am I missing something obvious or is there just no way to support editing tests in the text editor of your choice? I thought that would be an MVP kind of thing. Or is this feature not implemented because it kind of competes with the paid Workspaces?
@manbradcalf have you found a way by chance or is this still DOA?
@manbradcalf have you found a way by chance or is this still DOA?
No.
I ended up migrating the tests that lived inside my Postman collections to a source-controlled node / mocha / chai / axios project.
Node for the runtime Mocha for the test runner Chai for the assertions Axios to make the http calls
@manbradcalf have you found a way by chance or is this still DOA?
No.
I ended up migrating the tests that lived inside my Postman collections to a source-controlled node / mocha / chai / axios project.
Node for the runtime Mocha for the test runner Chai for the assertions Axios to make the http calls
Yah, that seems like a much better strategy. I was leaning in a similar direction myself. Too bad, postman/newman. 😞