jejacks0n / teaspoon

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

Can't find variable: expect #426

Closed ephracis closed 9 years ago

ephracis commented 9 years ago

Added this to Gemfile:

group :test, :development do
  gem 'teaspoon-mocha'
end

Then ran bundle followed by the installation generator:

✗ rails generate teaspoon:install --coffee
      create  spec/teaspoon_env.rb
      create  spec/javascripts/support
      create  spec/javascripts/fixtures
      create  spec/javascripts/spec_helper.coffee
+============================================================================+
Congratulations!  Teaspoon was successfully installed.  Documentation and more
can be found at: https://github.com/modeset/teaspoon

I then created spec/javascripts/test_spec.js.coffee with the following content:

describe "My great feature", ->

  it "will change the world", ->
    expect(true).to.be(true)

  it "will destroy the world", ->
    expect(true).to.be(false)

Then tried to run the tests:

✗ rake teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:65447/teaspoon/default
FF

Failures:

  1) My great feature will change the world
     Failure/Error: Can't find variable: expect

  2) My great feature will destroy the world
     Failure/Error: Can't find variable: expect

Finished in 0.01000 seconds
2 examples, 2 failures

Failed examples:

teaspoon -s default --filter="My great feature will change the world"
teaspoon -s default --filter="My great feature will destroy the world"
rake teaspoon failed

Nothing else has changed. Running OS X 10.11.1.

mikepack commented 9 years ago

Mocha doesn't ship with an assertion syntax. You'll need to add Chai and enable expect.

In your spec_helper.coffee:

#= require support/chai
window.expect = chai.expect