Question

I have some Jasmine tests for my (currently) very simple site consisting of a Rails back end and an AngularJS front end. I'm trying to do some Jasmine end-to-end testing, but including angular-scenario.js makes my tests not run. It doesn't make them fail. It makes them not start at all.

I'm using version 1.0.7, and all the Angular files are from the same version (and all from the official Angular site. The version of Rails I'm using is 3.1.3 with Ruby 1.9.3. I'm also using the jasmine gem version 1.3.2 and jasmine-rails 0.4.5.

spec/javascripts/support/jasmine.yml:

src_files:
  - assets/application.{js,coffee}
stylesheets:
  - stylesheets/**/*.css
helpers:
  - helpers/**/*.{js,coffee}
  - lib/angular-scenario.js
spec_files:
  - '**/*[sS]pec.{js,coffee}'
src_dir: 'app/assets/javascripts'
spec_dir: spec/javascripts

spec/javascripts/spec_helper.coffee:

#= require angular.min
#= require angular-mocks

spec/javascripts/templates/brands/index_spec.coffee:

describe 'test', () ->
  it 'works', () ->
    expect(true).toEqual(true)

Of course, that's just a placeholder until I can get the test work correctly with angular-scenario.js in place.

Without angular-scenario.js, the tests run. With it, nothing.

To test, I typically run RAILS_ENV=test rake spec:javascript, but I've also tried from the web server interface.

The output without angular-secnario.js:

Starting...

Finished
-----------------
1 spec, 0 failures in 0.005s.

ConsoleReporter finished

The output with angular-scenario.js:

Starting...

Finished
-----------------
0 specs, 0 failures in 0s.

ConsoleReporter finished

Things I've tried:

  • Moving angular-scenario.js to vendor/assets/javacripts and requiring it from spec_helper.coffee.
  • Removing either other Angular-related requirement from spec_helper.coffee.
  • angular-scenario.js comes with jQuery packaged with it. Commenting out the jQuery bit, oddly enough, makes the tests run, though they fail because angular-scenario needs jQuery, apparently. I also tried commenting out the jQuery in angular-scenario and including jQuery from the jquery-rails gem. (That was a shot in the dark. I didn't think that would actually work.)

Thank you very much to whoever wants to take a swing at this one.

Was it helpful?

Solution

Jasmine and angular-scenario.js (e2e runner) are two different things and they should be run separately. Angular e2e test framework uses syntax which is very similar to jasmine. Probably when you include it along with jasmine it overrides some jasmine's methods like describe, it and beforeEach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top