olimorris / neotest-rspec

🧪 Neotest adapter for RSpec. Works in Docker containers too
MIT License
90 stars 26 forks source link

Test output shows JSON #9

Closed bmulholland closed 2 years ago

bmulholland commented 2 years ago

When I look at the test output, I expect to see human-friendly information about the test (and any failures): https://github.com/nvim-neotest/neotest#output-window

Instead, I see human-unfriendly JSON (rspec's JSON output, specifically).

This is a tricky one. Three options I can see:

  1. Somehow get RSpec to output both human-friendly and machine-friendly formats, then parse/correlate them.
  2. Switch to human-friendly output and figure out how to parse that for results.
  3. Parse/format the JSON blob into something human readable.

3 is my favourite, but a good starting point is probably to check how neotest-pytest does it, considering that's the example in the README screenshot. https://github.com/nvim-neotest/neotest-python

olimorris commented 2 years ago

I hadn't actually used the output window except for failing tests (which should look quite reasonable) and you're quite right, it is "human-unfriendly".

I think we can get around this by specifying multiple formats in the command such as bundle exec rspec -f json -o output.json -f progress spec/simple_example_spec.rb. I'll look into this later today

bmulholland commented 2 years ago

I did try a failing test too -- there was a nice output view that popped up automatically, but if I manually opened test output with the neotest command, JSON was still shown. I don't understand where that initial nicely-formatted output came from, though...

olimorris commented 2 years ago

It's from here:

if result.exception then
  tests[test_id].short = tests[test_id].short .. '\n' .. result.exception.message
  tests[test_id].errors = result.exception.backtrace
end

I think I can pass stdout to the output key in the test results.

bmulholland commented 2 years ago

That makes sense. stdout to output makes sense to me, too.

olimorris commented 2 years ago

Hopefully should be fixed for you:

Screen Shot 2022-06-16 at 19 54 30@2x
bmulholland commented 2 years ago

Beautiful!