jejacks0n / teaspoon

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

gem `rack-mini-profiler` has problems with rake task #270

Closed skinofstars closed 10 years ago

skinofstars commented 10 years ago

EDIT - rack-mini-profiler is causing issues. See first comment.


Seem to be hitting a couple of issues with new Teaspoon install. After setting up fresh Rails and PhantomJS, I run the following commands:

  1. rails g teaspoon:install --framework=qunit
  2. rake teaspoon

First issue is needing to add Rails.application.config.assets.precompile += %w( teaspoon.css qunit/1.14.0.js teaspoon-qunit.js ) to /config/initializers/asset.rb. But that's no big problem. The errors are clear enough.

After that, I get

Failures:

  1)  global failure (1, 0, 1)
     Failure/Error: SyntaxError: Parse error

Finished in 0.02800 seconds
1 example, 1 failure

I understand from reading other issues that the failure is a QUnit test? Still, I'm a bit stumped as to how to resolve this. Was there more configuration I needed to do?

I've also checked this with Jasmine to be sure it wasn't just QUnit. You get the same assets.precompile errors. You also get a SyntaxError: Parse error warning, but the tests (or lack of) pass with 0 examples, 0 failures

I'm thinking for such a fresh start, it should probably be able to run QUnit. If more needs to be done, then probably something in the README.

Ok, long issue there. Thanks for reading :)

skinofstars commented 10 years ago

Ahhhhh!

Ok, so I missed a bit of info in the README. Namely, that the CLI runs in the development environment. That probably wouldn't be an issue, but I have the rack-mini-profiler gem installed, which is injecting some DOM elements which is messing things up.

I'll be investigating further, but I'm guessing I'll have to take my fixes to that gem rather than here.

Feel free to close this if you like.

Thanks

jejacks0n commented 10 years ago

No, that's actually really interesting, so thanks for the heads up.. Hmm.. If there's a way to tell rack-mini-profiler not to do it's thing you could put that in the teaspoon_env.rb, but I didn't see anything in their readme, and assume it's just a "if loaded do it" sort of gem.

The reason Teaspoon prefers development is because of caching and a few other minor things, but you're welcome to change the env to test. You can set it in the teaspoon_env.rb or with the rake command RAILS_ENV=test rake teaspoon.

Hopefully that gets you down the right path.. I'm tagging this as info though. Thanks.

skinofstars commented 10 years ago

It's possible to disable rack-mini-profiler by hitting ?pp=disable first with PhantomJS (see ?pp=help for more options).

That said, I kinda would expect Teaspoon to use test env by default. It is a test runner after all :)

In my case, I just put this in my circle.yml and all was fine

test:
  post:
    - bundle exec teaspoon:
        environment:
          RAILS_ENV: test
jejacks0n commented 10 years ago

cool.. so, it's a long long story.. but the way assets work in the browser (eg. /teaspoon), and how they work in the test environment can be configured in a vastly different way.

So I'll just give you one example of that. In test, assets are configured by default to be combined, so you would get a line number of application.js:4572 instead of the actual.js:24. If that's what you're shooting for that's ok, but it's a struggle to get it to behave in any consistent way with the various asset configuration options that can exist in dev and test environments. Like I said, you can opt into that, and it's not forced, but you will see differences and experience confusion because of it, so it's an opt in, not an opt out.

Thanks for the info though, that's good to know.

ghost commented 9 years ago

@skinofstars I've found a seemingly much easier way to avoid Teaspoon and rack-mini-profiler clashing:

Rack::MiniProfiler.config.skip_paths << '/teaspoon'

Throw that in an initializer and you should be good to go to use Teaspoon in the development environment.

@jejacks0n Would it be worth putting this in the readme or FAQ?

jejacks0n commented 9 years ago

Absolutely! thanks so much for the info. You want to submit a PR, or have me do it? It might be a week or two before I can get around to it.

ghost commented 9 years ago

@jejacks0n I'd be happy to submit a PR. Will set a reminder for myself to do that tomorrow!