jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Teaspoon and the Asset pipeline (re: a react question hah) #432

Closed rstudner closed 8 years ago

rstudner commented 8 years ago

I was wondering if teaspoon could make sure of the various transpilers in the asset pipeline.. specifically, why I can't write:

myComponent_spec.js.jsx

and thus put JSX statements etc into my tests. Would make the testing of React components much much easier and since React is so popular, would give some more legs to the use cases teaspoon happily supports.

Thoughts?

jejacks0n commented 8 years ago

if they're part of sprockets, they get transpiled.

rstudner commented 8 years ago

Hrm. I'm having mixed results.

I have a file: AjaxSuccessFailureButton_spec.js.jsx in spec/javascripts/components

It isn't in the list of tests.

If I rename it to just .js (no jsx)

It shows up in the list of tests.

Thoughts?

jejacks0n commented 8 years ago

Ah, sorry. You can read about it in the Teaspoon configuration, specifically the matcher configuration directive.

jejacks0n commented 8 years ago

I'm unsure why your spec would be a .jsx, but have at it. =)

rstudner commented 8 years ago

Hah yeah.. just for React stuff, especially with multiple components, it just way easier to render them into the DOM/configure their props using the JSX syntax. The "pure js" React syntax is fine for doing really trivial things, but if you want to make a mock component (re: chunk of DOM) to use with a react widget (think "yield") it gets to be insane without JSX.

jejacks0n commented 8 years ago

Sounds cool. I haven't had the opportunity to get into React yet. Hope you're sorted now though. =)

rstudner commented 8 years ago

Yep, is working perfectly. I had the default matcher (as you suspected) and just forgot about that entire part of the Docs since it'd been so long since I'd had to get in there.

Thanks for the prompt responses and help -- much appreciated.

I'll try to update your docs (if you like) with a little subsection on 'setting up to test React' based on these little config tweaks etc.

jejacks0n commented 8 years ago

Yeah man, feel free to create a wiki article for it -- would be super valuable to others I'm sure.