Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
support nightwatch case
Browse files Browse the repository at this point in the history
  • Loading branch information
archlichking committed Jun 7, 2018
1 parent c14f1bc commit 9cd7be7
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 65 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 7 additions & 0 deletions src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
152 changes: 91 additions & 61 deletions test/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const sinon = require("sinon");
const _opts = (opts) => {
return _.merge({
console: {
log: () => {}
log: () => { }
},
fs: {
writeFileSync: () => {}
writeFileSync: () => { }
},
settings: {
verbose: true,
Expand Down Expand Up @@ -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();
}
});
});
});

Expand All @@ -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();
}
});
});
});

Expand All @@ -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();
}
});
});
});
});

Expand All @@ -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();
}
});
});
});
});
});

0 comments on commit 9cd7be7

Please sign in to comment.