-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for yui#78, bad output for moduleless QUnit.
- Loading branch information
Showing
3 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
"use strict"; | ||
|
||
var vows = require("vows"); | ||
var assert = require("assert"); | ||
|
||
var portfinder = require("portfinder"); | ||
|
||
var hub = require("../lib/hub"); | ||
var cliTopic = require("../lib/cli"); | ||
|
||
var EventEmitter2 = require("../../lib/event-emitter"); | ||
|
||
vows.describe("Yeti JUnit Functional").addBatch({ | ||
"A Yeti CLI with moduleless QUnit with JUnit output": { | ||
topic: cliTopic(function (topic) { | ||
var vow = this; | ||
|
||
topic.stderr.startCapture(); | ||
|
||
portfinder.getPort(function (err, port) { | ||
if (err) { | ||
vow.callback(err); | ||
return; | ||
} | ||
|
||
port = String(port); | ||
topic.port = port; | ||
|
||
topic.stderr.expect("When ready", function () { | ||
topic.stderr.stopCapture(); | ||
topic.output = topic.stderr.capturedData; | ||
vow.callback(null, topic); | ||
}); | ||
|
||
topic.fe.route([ | ||
"node", | ||
"cli.js", | ||
"--junit", | ||
"-p", port, | ||
__dirname + "/fixture/qunit.html" | ||
]); | ||
}); | ||
}), | ||
"is ok": function (topic) { | ||
assert.isUndefined(topic.stack); | ||
}, | ||
"prints hub creation message on stderr": function (topic) { | ||
assert.ok(topic.output.indexOf("Creating a Hub.") === 0); | ||
}, | ||
"waits for agents to connect on stderr": function (topic) { | ||
assert.include(topic.output, "Waiting for agents to connect"); | ||
}, | ||
"prompts on the writableStream": function (topic) { | ||
assert.include(topic.output, "When ready, press Enter"); | ||
}, | ||
"a browser": hub.phantomContext({ | ||
"visits Yeti": { | ||
topic: function (browser, topic) { | ||
var vow = this; | ||
|
||
topic.browser = browser; | ||
|
||
topic.stderr.expect("Agent connected", function (err, capturedData) { | ||
topic.output = capturedData; | ||
vow.callback(null, topic); | ||
}); | ||
|
||
function onPageOpen(err, status) { | ||
if (err) { | ||
vow.callback(err); | ||
} | ||
} | ||
|
||
browser.createPage(function (err, page) { | ||
page.open("http://localhost:" + topic.port, onPageOpen); | ||
}); | ||
}, | ||
"is ok": function (topic) { | ||
assert.isUndefined(topic.stack); | ||
}, | ||
"the stderr output contains the User-Agent": function (topic) { | ||
assert.include(topic.output, "PhantomJS"); | ||
}, | ||
"when Enter is pressed": { | ||
topic: function (topic) { | ||
var vow = this; | ||
|
||
topic.stderr.expect("pass", function (err, capturedData) { | ||
topic.output = capturedData; | ||
vow.callback(null, topic); | ||
}); | ||
|
||
topic.stdout.startCapture(); | ||
|
||
topic.stdin.write("\n"); // Enter | ||
}, | ||
"is ok": function (topic) { | ||
assert.isUndefined(topic.stack); | ||
}, | ||
"the stderr output contains the test summary": function (topic) { | ||
// FIXME, tests should be test | ||
assert.include(topic.output, "1 tests passed"); | ||
}, | ||
"the stderr output contains Agent complete": function (topic) { | ||
assert.include(topic.output, "Agent complete"); | ||
}, | ||
"should exit": { | ||
topic: function (topic) { | ||
var vow = this; | ||
topic.emitter.once("exit", function (code) { | ||
topic.stdout.stopCapture(); | ||
topic.exitCode = code; | ||
vow.callback(null, topic); | ||
}); | ||
}, | ||
"with status code 0": function (topic) { | ||
assert.strictEqual(topic.exitCode, 0); | ||
}, | ||
"the stdout output contains JUnit XML": function (topic) { | ||
assert.ok(topic.stdout.capturedData.indexOf("<?xml") === 0); | ||
assert.include(topic.stdout.capturedData, "</testsuites>"); | ||
}, | ||
"the stdout output contains a JUnit testcase": function (topic) { | ||
// https://github.com/yui/yeti/issues/78 | ||
assert.include(topic.stdout.capturedData, '<testcase name="hello qunit: test1"'); | ||
} | ||
} | ||
} | ||
} | ||
}) // phantomContext | ||
} | ||
}).export(module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
var streams = require("mock-utf8-stream"); | ||
|
||
var EventEmitter2 = require("../../lib/event-emitter"); | ||
var CLI = require("../../lib/cli").CLI; | ||
|
||
module.exports = function cliTopic(fn) { | ||
return function () { | ||
var vow = this, | ||
topic, | ||
emitter = new EventEmitter2(); | ||
|
||
topic = { | ||
fe: null, | ||
stdin: new streams.MockReadableStream(), | ||
stdout: new streams.MockWritableStream(), | ||
stderr: new streams.MockWritableStream(), | ||
emitter: emitter | ||
}; | ||
|
||
function mockExit(code) { | ||
emitter.emit("exit", code); | ||
} | ||
|
||
topic.fe = new CLI({ | ||
stdin: topic.stdin, | ||
stdout: topic.stdout, | ||
stderr: topic.stderr, | ||
exitFn: mockExit | ||
}); | ||
|
||
return fn.call(vow, topic); | ||
}; | ||
}; |