Skip to content

Commit fd986fe

Browse files
committed
Dangerfile: handle jasmine-maven-plugin.
1 parent 8addaca commit fd986fe

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Dangerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,34 @@ else
265265
end
266266
end
267267

268+
# Handle `mvn jasmine:test` report
269+
#
270+
# Example:
271+
# <testsuite errors="0" name="jasmine.specs" tests="22" failures="3" skipped="0" hostname="localhost" time="0.0" timestamp="2017-03-09T19:52:06">
272+
# <testcase classname="jasmine" name="CatalogUtils.expandNumbers() should return string without hyphen as it" time="0.0" failure="true">
273+
# <error type="expect.toEqual" message="Expected 'test' to equal '2test'.">Expected 'test' to equal '2test'.</error>
274+
# </testcase>
275+
# </testsuite>
276+
#
277+
jasmine_report = 'target/jasmine/TEST-jasmine.xml'
278+
unless File.file?(jasmine_report)
279+
warn("Couldn't find #{jasmine_report}. jasmine-maven-plugin results is unknown")
280+
else
281+
doc = Nokogiri::XML(File.open(jasmine_report))
282+
testsuite = doc.xpath('/testsuite').first
283+
failures = testsuite['failures'].to_i
284+
if failures > 0
285+
testsuite.xpath('.//testcase[@failure="true"]').each do |tc|
286+
# NOTE: unfortunately jasmine report doesn't contain file name
287+
msg = tc.xpath('./error').first.text.sub(/\.$/, '')
288+
testcase = tc['name']
289+
fail("jasmine-maven-plugin error:\nTest case `#{testcase}` fails with message:\n`#{msg}`\n")
290+
end
291+
292+
print_errors_summary 'jasmine-maven-plugin', failures, 'https://github.com/php-coder/mystamps/wiki/unit-tests-js'
293+
end
294+
end
295+
268296
# Handle `html5validator` output
269297
#
270298
# Example:

0 commit comments

Comments
 (0)