jejacks0n / teaspoon

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

How to prevent teaspoon from loading js files separately? #124

Closed alisnic closed 10 years ago

alisnic commented 10 years ago

I've put config.assets.debug = false in config/development.rb, but teaspoon loads each js separately with body=1 appended to path. (that happens in /teaspoon)

My main application does everything well in dev mode and all js is concatenated to one file.

Do you have any suggestions? Loading each js file separately makes my tests painfully slow (~150 js files)

alisnic commented 10 years ago

Modifying teaspoon spec views to use javascript_include_tag instead of using javascript_include_tag_for_teaspoon made /teaspoon orders of magnitude faster. It seems that javascript_include_tag_for_teaspoon is ignoring config.assets.debug

jejacks0n commented 10 years ago

So, that's there for two reasons. The first is because sprockets had a bug (I think this was in rails 3.2.12, and I fixed it there, and in sprocket-rails for rails 4), where in it would load the same file more than once.. so if you required the same file in multiple sources it would load that many times -- often times overwriting things and causing unexpected behavior. There are other issues here where I go into this in more detail.

The second reason is for stack traces.. if all files are combined into one, the stack traces aren't very useful, but this is up to you to determine.

With those things being explained, you're welcome to provide your own layout where you call javascript_include_tag directly. That's easy, just copy the one from the gem and put it in your own application. Now that you're aware of the entire picture you're welcome to do whatever you like.

jejacks0n commented 10 years ago

I would take a pull request for a generator that copies the layout into the application.. that way I can update the readme to explain this, and how to get around it.

alisnic commented 10 years ago

thanks for the explanation, i found out how to do it. indeed a custom layout did the thing. On Oct 28, 2013 5:40 PM, "jejacks0n" notifications@github.com wrote:

I would take a pull request for a generator that copies the layout into the application.. that way I can update the readme to explain this, and how to get around it.

— Reply to this email directly or view it on GitHubhttps://github.com/modeset/teaspoon/issues/124#issuecomment-27222807 .