give better messages with javascript errors

This commit is contained in:
John Bintz 2011-05-31 09:37:29 -04:00
parent ccafb37bbe
commit 3f630c73e9
5 changed files with 52 additions and 16 deletions

View File

@ -248,7 +248,13 @@ void HeadlessSpecRunner::finishSuite(const QString &duration, const QString &tot
std::cout << "FAIL: "; std::cout << "FAIL: ";
} else { } else {
green(); green();
std::cout << "PASS: "; std::cout << "PASS";
if (hasErrors) {
std::cout << " with JS errors";
}
std::cout << ": ";
} }
std::cout << qPrintable(total) << " tests, " << qPrintable(failed) << " failures, " << qPrintable(duration) << " secs."; std::cout << qPrintable(total) << " tests, " << qPrintable(failed) << " failures, " << qPrintable(duration) << " secs.";
@ -280,10 +286,9 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
if (hasErrors && m_runs > 2) if (hasErrors && m_runs > 2)
QApplication::instance()->exit(1); QApplication::instance()->exit(1);
if (!hasErrors) {
if (isFinished) { if (isFinished) {
int exitCode = 0; int exitCode = 0;
if (didFail) { if (didFail || hasErrors) {
exitCode = 1; exitCode = 1;
} else { } else {
if (usedConsole) { if (usedConsole) {
@ -299,7 +304,6 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
QApplication::instance()->exit(1); QApplication::instance()->exit(1);
} }
} }
}
#include "specrunner.moc" #include "specrunner.moc"

View File

@ -24,6 +24,20 @@ describe "jasmine-headless-webkit" do
end end
end end
describe 'success but with js error' do
it "should succeed with error code 0" do
system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
$?.exitstatus.should == 1
parts = File.read(report).strip.split('/')
parts.length.should == 4
parts[0].should == "1"
parts[1].should == "0"
parts[2].should == "F"
end
end
describe 'failure' do describe 'failure' do
it "should fail with an error code of 1" do it "should fail with an error code of 1" do
system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}} system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}}

View File

@ -0,0 +1,3 @@
var good = 2;
var bad = null;
if (bad.myProperty) {}

View File

@ -0,0 +1,9 @@
src_files:
- spec/jasmine/success_with_error/success_with_error.js
spec_files:
- spec/jasmine/success_with_error/success_with_error_spec.js
src_dir: .
spec_dir: .

View File

@ -0,0 +1,6 @@
describe('Success with error', function() {
it("should not fail", function() {
expect(good).toEqual(2);
})
});