Closed henrik closed 6 years ago
We hope to provide a baked-in solution for 1.0 that may look something like https://github.com/stimulusjs/stimulus/pull/7. And, of course, you can use your application's existing test rig. We write high level feature tests using http://guides.rubyonrails.org/testing.html#system-testing.
@javan, thank you very much!
Quick update on testing.
We introduced the @stimulus/test
package in version 1.0.0: https://github.com/stimulusjs/stimulus/pull/58
It’s currently undocumented but used internally by other @stimulus
packages. You can review their test suites here:
You can use this library to test your applications right now. The API is stable. What we haven’t done yet is polish the experience around setting up and invoking Karma.
@sstephenson It's been a while since this was posted, I was wondering if there was an update to the testing's suite documentation? I could not find a reference to it in your repo / handbook site.
Happy new year! Any updates on this? It looks like there was a planned test harness for 1.1 that didn't make the cut (https://discourse.stimulusjs.org/t/what-s-planned-for-stimulus-1-1/144).
This is very, very much appreciated @shime. Do you have any experience testing them through RSpec?
@nogtini I'm not 100% sure what do you mean by that. Before we started using Jest for this, we used to test Stimulus controllers through ordinary Rails system tests, so that's another approach you could take.
@shime Sure, I mean only in the context of integration tests. Seeing stimulus controllers tested through something like Capybara I think would help for people who are newer to Rails overall, like me. I come from a JS background, so seeing how these things are tested within the context of an entire working application is often difficult to discern.
Copying the component in as a fixture instead of directly testing app code doesn't bode well for catching regressions. It seems like it would be better to only test functions which transform data, leaving others that do UI interactions to the system tests.
Do you have any thoughts on testing Stimulus controllers? Do you tend to unit test them in part or whole? Or rely on integrated feature tests that incorporate JS?