Skip to content

Commit 1a3aa92

Browse files
committed
Dangerfile: handle jasmine-maven-plugin report.
1 parent cee5bff commit 1a3aa92

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Dangerfile

+28
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,34 @@ else
329329
end
330330
end
331331

332+
# Handle `mvn jasmine:test` report
333+
#
334+
# Example:
335+
# <testsuite errors="0" name="jasmine.specs" tests="22" failures="3" skipped="0" hostname="localhost" time="0.0" timestamp="2017-03-09T19:52:06">
336+
# <testcase classname="jasmine" name="CatalogUtils.expandNumbers() should return string without hyphen as it" time="0.0" failure="true">
337+
# <error type="expect.toEqual" message="Expected 'test' to equal '2test'.">Expected 'test' to equal '2test'.</error>
338+
# </testcase>
339+
# </testsuite>
340+
#
341+
jasmine_report = 'target/jasmine/TEST-jasmine.xml'
342+
unless File.file?(jasmine_report)
343+
warn("Couldn't find #{jasmine_report}. jasmine-maven-plugin results is unknown")
344+
else
345+
doc = Nokogiri::XML(File.open(jasmine_report))
346+
testsuite = doc.xpath('/testsuite').first
347+
failures = testsuite['failures'].to_i
348+
if failures > 0
349+
testsuite.xpath('.//testcase[@failure="true"]').each do |tc|
350+
# NOTE: unfortunately jasmine report doesn't contain file name
351+
msg = tc.xpath('./error').first.text.sub(/\.$/, '')
352+
testcase = tc['name']
353+
fail("jasmine-maven-plugin error:\nTest case `#{testcase}` fails with message:\n`#{msg}`\n")
354+
end
355+
356+
print_errors_summary 'jasmine-maven-plugin', failures, 'https://github.com/php-coder/mystamps/wiki/unit-tests-js'
357+
end
358+
end
359+
332360
# Handle `html5validator` output
333361
#
334362
# Example:

0 commit comments

Comments
 (0)