diff --git a/.travis.yml b/.travis.yml index 1aa2d8b..5f68911 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: node_js node_js: + - v8 - v7 - v6 - - v5 - - v4 sudo: false after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/package.json b/package.json index 36f4e0c..988bf74 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "testarmada-magellan-xunit-reporter", - "version": "0.0.3", + "version": "0.0.6", "description": "Magellan xUnit reporter plugin", "main": "index.js", "scripts": { - "test": "mocha && npm run lint && npm run coverage && npm run check-coverage", + "test": "npm run lint && mocha && npm run coverage && npm run check-coverage", "dev-test": "mocha", "lint": "eslint *.js src/*.js test/**", "coverage": "istanbul cover _mocha -- --recursive", diff --git a/src/reporter.js b/src/reporter.js index 432fd12..f5aac34 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -72,6 +72,13 @@ class Reporter { duration: test.runningTime, err: {} }; + + if (test.locator.filename) { + // patch for nightwatch test + testObject.title = test.locator.filename; + testObject.fullTitle = test.locator.filename; + } + this.tests.push(testObject); this.suites.push(test.locator.filename); if (msg.passed) { diff --git a/test/reporter.js b/test/reporter.js index 029985c..b923207 100644 --- a/test/reporter.js +++ b/test/reporter.js @@ -8,10 +8,10 @@ const sinon = require("sinon"); const _opts = (opts) => { return _.merge({ console: { - log: () => {} + log: () => { } }, fs: { - writeFileSync: () => {} + writeFileSync: () => { } }, settings: { verbose: true, @@ -77,17 +77,17 @@ describe("reporter", () => { title: "foo" } }, { - addListener: (name, cb) => { - expect(name).to.eql("message"); - expect(cb).to.not.be.null; - cb({ - type: "worker-status", - passed: true, - status: "finished" - }); - done(); - } - }); + addListener: (name, cb) => { + expect(name).to.eql("message"); + expect(cb).to.not.be.null; + cb({ + type: "worker-status", + passed: true, + status: "finished" + }); + done(); + } + }); }); }); @@ -103,22 +103,52 @@ describe("reporter", () => { pending: true } }, { - addListener: (name, cb) => { - expect(name).to.eql("message"); - expect(cb).to.not.be.null; - cb({ - type: "worker-status", - passed: true, - status: "finished" - }); - try { - r.flush(); - } catch (e) { - console.log(e); + addListener: (name, cb) => { + expect(name).to.eql("message"); + expect(cb).to.not.be.null; + cb({ + type: "worker-status", + passed: true, + status: "finished" + }); + try { + r.flush(); + } catch (e) { + console.log(e); + } + done(); } - done(); + }); + }); + }); + + it("should handle nightwatch case", (done) => { + const r = new Reporter(_opts({})); + r.initialize().then(() => { + r.listenTo("a", { + maxAttempts: 2, + attempts: 1, + locator: { + filename: "foo", + pending: true } - }); + }, { + addListener: (name, cb) => { + expect(name).to.eql("message"); + expect(cb).to.not.be.null; + cb({ + type: "worker-status", + passed: true, + status: "finished" + }); + try { + r.flush(); + } catch (e) { + console.log(e); + } + done(); + } + }); }); }); @@ -134,26 +164,26 @@ describe("reporter", () => { }, runningTime: 100 }, { - addListener: (name, cb) => { - expect(name).to.eql("message"); - expect(cb).to.not.be.null; - cb({ - type: "worker-status", - status: "weird" - }); - cb({ - type: "worker-status", - passed: true, - status: "finished" - }); - try { - r.flush(); - } catch (e) { - console.log(e); + addListener: (name, cb) => { + expect(name).to.eql("message"); + expect(cb).to.not.be.null; + cb({ + type: "worker-status", + status: "weird" + }); + cb({ + type: "worker-status", + passed: true, + status: "finished" + }); + try { + r.flush(); + } catch (e) { + console.log(e); + } + done(); } - done(); - } - }); + }); }); }); @@ -170,22 +200,22 @@ describe("reporter", () => { stdout: "", runningTime: 100 }, { - addListener: (name, cb) => { - expect(name).to.eql("message"); - expect(cb).to.not.be.null; - cb({ - type: "worker-status", - passed: false, - status: "finished" - }); - try { - r.flush(); - } catch (e) { - console.log(e); + addListener: (name, cb) => { + expect(name).to.eql("message"); + expect(cb).to.not.be.null; + cb({ + type: "worker-status", + passed: false, + status: "finished" + }); + try { + r.flush(); + } catch (e) { + console.log(e); + } + done(); } - done(); - } - }); + }); }); }); });