Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails teaspoon Testing in engine Not loading *_spec.js

i'm working on an engine (gem) that has some js code to be tested but seems i can't get it working. I've followed the wiki article and set a basic example, but i'm only getting 0 examples, 0 failures.

Steps done:

  • Added s.add_development_dependency 'teaspoon-jasmine' in the gemspec file
  • dummy is in spec/dummy
  • spec/teaspoon_env.rb:

    unless defined?(Rails)
      ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
      require File.expand_path("#{ENV["RAILS_ROOT"]}/config/environment", __FILE__)
    end
    
    Teaspoon.configure do |config|
       ...
       config.root = MyEngineName::Engine.root
       ...
    end
    
  • Rakefile:

    desc "Run the javascript specs"
    task :teaspoon => "app:teaspoon"
    
  • spec/javascripts/spec_helper.js (default as it was generated)
  • spec/javascripts/example_spec.js:

    describe("My great feature", function() {
      it("Bang", () => {
        expect(true).toBe(false);
      });
    });
    

The problem is that when i try to run the test engine, i'm getting:

    $> teaspoon 
    Starting the Teaspoon server...
    Thin web server (v1.7.0 codename Dunder Mifflin)
    Maximum connections set to 1024
    Listening on 127.0.0.1:57036, CTRL+C to stop
    Teaspoon running default suite at http://127.0.0.1:57036/teaspoon/default


    Finished in 0.01600 seconds
    0 examples, 0 failures

I've also try to run the following commands, with the same result:

  • $> bundle exec teaspoon
  • $> rake teaspoon
  • $> bundle exec teaspoon spec/javascripts/example_spec.js
  • And even $> bundle exec teaspoon spec/javascripts/non_existent_file_spec.js

I have not much idea of what is not working. As non standard app, i'm using es6 through browserify-rails (which is working ok), and got in engine.rb:

    config.browserify_rails.paths = [
        lambda { |p| p.start_with?(MyEngineName::Engine.root.join("app").to_s) }
    ]

Any help or clue would be much appreciated.

UPDATE:

I've created an engine from strach so it is easy to check and reproduce the issue.

Repo Engine example

In particular, the commit related to the teaspoon setup is this one

like image 390
ngelx Avatar asked Jul 05 '16 10:07

ngelx


1 Answers

It is due to the arrow function in your test. Change it to vanilla JS to make it work:

it("Bang", function() {
  expect(true).toBe(false);
});

The browser option works just fine with es6.

like image 191
chipairon Avatar answered Oct 26 '22 23:10

chipairon