Skip to content

Commit

Permalink
Add number of assertions, failures, etc to Minitest output as structu…
Browse files Browse the repository at this point in the history
…red data
  • Loading branch information
noahgibbs committed Jul 9, 2024
1 parent d175293 commit bf73b10
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/space_shoes/guest/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,28 @@ def e.shutdown; end
def e.start; end
Minitest.parallel_executor = e # No threads available in ruby.wasm
result = Minitest.run []
# TODO: add a DOM element or similar so we know when this is complete
JS.global[:document][:shoes_spec_passed] = result
test_details = ShoesSpec.test_class.results # Should only be one test class

JS.global[:document][:shoes_spec] = {}

JS.global[:document][:shoes_spec][:passed] = result
JS.global[:document][:shoes_spec][:cases] = test_details[:cases]
JS.global[:document][:shoes_spec][:assertions] = test_details[:assertions]
JS.global[:document][:shoes_spec][:failures] = test_details[:failures]
JS.global[:document][:shoes_spec][:errors] = test_details[:errors]
JS.global[:document][:shoes_spec][:skips] = test_details[:skips]
JS.global[:document][:shoes_spec][:err_objects] = test_details[:results].inspect

elt = JS.global[:document].createElement("div")
elt[:className] = "minitest_result"
test_details = ShoesSpec.test_class.results # Should only be one test class

elt[:dataset][:cases] = test_details[:cases]
elt[:dataset][:assertions] = test_details[:assertions]
elt[:dataset][:failures] = test_details[:failures]
elt[:dataset][:errors] = test_details[:errors]
elt[:dataset][:skips] = test_details[:skips]
elt[:dataset][:err_objects] = test_details[:results].inspect

elt[:innerHTML] = "<p>#{result ? "passed" : "failed"}</p><p>#{test_details}</p>"
JS.global[:document][:body].appendChild(elt)

Expand Down

0 comments on commit bf73b10

Please sign in to comment.