mayu-live/framework

Testing apps

aalin opened this issue · 0 comments

aalin commented

Without testing there is no way to know if anything works.

I'm thinking there could be page tests, component tests and store tests...
I really like how Testing Library does queries by roles, it encourages accessibility, and their API is pretty nice so it's a good source of inspiration

Page tests could look like this:

# app/pages/my-page/page.test.rb

def test_my_page
  page = Blabla.new(setup_env)
  page.navigate "/my-page"
    
  page.click(page.get_by_text("Load Greeting"))
  page.find_by_role("heading")

  assert(page.get_by_role("heading").text_content == "hello there")
  assert(page.get_by_role("heading").button.disabled)
end
# app/components/MyComponent.test.rb

def test_my_component
  component = render("%MyComponent")
  # now what? suggestions welcome
end

It would maybe be possible to use Capybara by implemeting a driver. That could save some work.