qase-tms / qase-javascript

Qase TMS JavaScript SDK
https://developers.qase.io
49 stars 43 forks source link

Qase reporter in newman reports 2x results #99

Closed ejerskov closed 2 years ago

ejerskov commented 2 years ago

Im using the qase-reporter for newman like this (the runId is retrieved by creating a run above this code):

newman.run({
      collection: 'postman_collection.json',
      environment: 'postman_environment.json',
      reporters: ['cli', 'qase'],
      reporter: {
          qase: {
              apiToken: "x",
              projectCode: "x",
              runId: runId,
              logging: true
          }
      }
}

This is the cli log (note that all results are posted twice which is also reflected in the Test Run on app.qase.io):

→ Test request
qase: Test Test request starting, case ids: [ '1' ]
qase: Test Test request starting, case ids: [ '1' ]
  GET https://httpstat.us/200 [200 OK, 1.29kB, 322ms]
  ✓  Status code is 200
qase: Test Test request passed
qase: Test Test request passed

→ Test request 2
qase: Test Test request 2 starting, case ids: [ '2' ]
qase: Test Test request 2 starting, case ids: [ '2' ]
  GET https://httpstat.us/500  qase: Project TEST exists
[500 Internal Server Error, 1.15kB, 192ms]
  1. Status code is 200
qase: Test Test request 2 failed
qase: Test Test request 2 failed

┌─────────────────────────┬────────────────────┬────────────────────┐
│                         │           executed │             failed │
├─────────────────────────┼────────────────────┼────────────────────┤
│              iterations │                  1 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│                requests │                  2 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│            test-scripts │                  2 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│      prerequest-scripts │                  0 │                  0 │
├─────────────────────────┼────────────────────┼────────────────────┤
│              assertions │                  2 │                  1 │
├─────────────────────────┴────────────────────┴────────────────────┤
│ total run duration: 608ms                                         │
├───────────────────────────────────────────────────────────────────┤
│ total data received: 31B (approx)                                 │
├───────────────────────────────────────────────────────────────────┤
│ average response time: 257ms [min: 192ms, max: 322ms, s.d.: 65ms] │
└───────────────────────────────────────────────────────────────────┘

  #  failure                                                      detail                                                                                                                                                                                                                                        

 1.  AssertionError                                               Status code is 200                                                                                                                                                                                                                            
                                                                  expected response to have status code 200 but got 500                                                                                                                                                                                         
                                                                  at assertion:0 in test-script                                                                                                                                                                                                                 
                                                                  inside "Test request 2"                                                                                                                                                                                                                       
qase: Run finished
qase: Run finished
qase: Using run 17 to publish test results
qase: Result publishing: Test request case: 1
qase: Result publishing: Test request case: 1
qase: Result publishing: Test request 2 case: 2
qase: Result publishing: Test request 2 case: 2
qase: Result published: Test request case 1
qase: Result published: Test request 2 case 2
qase: Result published: Test request 2 case 2
qase: Result published: Test request case 1

The 2 postman tests are set up like this:

//qase: 1
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
//qase: 2
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
ejerskov commented 2 years ago

@nl-kaidzen The runner listener is added a second time here, causing it to report all results 2 times: https://github.com/qase-tms/qase-javascript/blob/master/qase-newman/src/index.ts#L87

Is it possible to do a quick PR on this issue?

nl-kaidzen commented 2 years ago

@ejerskov Yes, I see the problem. You can send a PR and we'll merge them very quickly, or I can fix this problem myself by Monday.

ejerskov commented 2 years ago

@nl-kaidzen, could you do the PR please?

kamilsk commented 2 years ago

Hi! fixed in 1.0.4 https://www.npmjs.com/package/newman-reporter-qase.