Closed jaredcwhite closed 4 years ago
The 0.15 release is pretty loaded, but as a stretch goal I think at least some foundational element of this could be included, perhaps as a blank folder in the site template or a suggested approach in the documentation.
Ugh. Testing terminology.
When I hear Integration Test
I think something that parses everything under the hood and doesn't use a browser.
IE:
Then there's End to End testing which would be something like:
It seems like Capybara weirdly hits both aspects based on my limited knowledge.
It can hook into Minitest or RSpec and work as integration testing. But it can also work as a Selenium driver (end to end testing) if I'm reading the docs correctly.
Most of the Rails / Ruby community would probably prefer Capybara due to familiarity.
But most of the front end world uses something like Enzyme / React-Testing-Library for integration tests and Cypress for end to end testing.
Sorry, just thinking out loud here. I'd be happy to see if I could throw something together with either Cypress and Dom-testing-Library or Capybara.
Theoretically they're both framework agnostic and shouldn't require anything special to get working.
I started to go down a path of using Minitest + Nokogiri via a Bridgetown hook to test the literal HTML at the point it's been statically generated, and so far I'm liking that approach as one possibility. (see #69)
If you want to give Cypress a spin for E2E testing, I think that'd be awesome. I've used Cypress a bit and it's pretty nifty, but I think it's mostly relevant only for parts of the site that are interactive and require JavaScript.
I just remembered Rails has a DOM testing library. It uses Minitest / Nokogiri under the hood.
I wonder if there would be any way to leverage those assertions.
Oooo, those look very interesting. Thanks for the link!!
The rails-dom-testing
stuff is pretty cool…using it now. I think #69 is in good shape now as an example. Since everything's done with just a local plugin and nothing changed in the core gems, I'll just plan to release an automation and document it if people want to add tests to their own sites. Thoughts @ParamagicDev?
Sounds perfect to me. I see no issues with this. Let people decide if / how they want to test their site.
Providing examples and an easy way to add them is definitely the way to do it as it prevents people feeling locked into any 1 specific suite.
We should integrate and demonstrate how to write integration tests that can be run in CI or during development to verify various aspects of site output, routes, components, etc. The field is wide open as far as I'm concerned as to the best way to do that. If we can stick to something simple and Ruby-based, that's cool. But I'm also willing to go for something heavy-duty like Cypress if that will better serve the ecosystem in the long run.