searls / jasmine-given

Like rspec-given, but for jasmine
testdouble.com
MIT License
178 stars 26 forks source link

TypeError: Object [object Object] has no method 'toHaveReturnedFalseFromThen' #39

Closed galenp closed 5 months ago

galenp commented 10 years ago

Hello

I am attempting to write coffeescript protractor e2e tests using jasmine-given.

Things seem to work for the most part, the tests run and the form is filled in and submitted but the Then statement fails with an error. It seems to fail regardless of my test...

login_spec.coffee

describe 'login spec', ->
  LoginView = require('./views/view-login.js')
  view = new LoginView();

  describe 'when a user logs in with correct details', ->
    Given -> view.fillEmail("test@test.com")
    Given -> view.fillPassword()
    When -> view.login()
    Then -> expect(view.currentUserName).toBeDefined()

top of protractor.conf

require('coffee-script/register');
require('jasmine-given');

And then it's a standard protractor conf.

Results

Failures:

  1) login spec when a user logs in with correct details then expect(view.currentUserName).toBeDefined()
   Message:
     TypeError: Object [object Object] has no method 'toHaveReturnedFalseFromThen'

Finished in 3.663 seconds
1 test, 1 assertion, 1 failure

I don't understand the error or what it could relate to. I've checked that toHaveReturnedFalseFromThen is part of jasmine-given.

Thanks in Advance

searls commented 10 years ago

Thanks for the detailed issue. I haven't used protractor in over a year, but I suspect this might be due to version problems. First, make sure you're running the very latest jasmine-given.

Next, if you could share a minimal sample project that'd be really fantastic for helping me debug. Cheers!

galenp commented 10 years ago

Test project setup

Instead of attaching a project I'll give you the full npm instructions to set up a test.

Assuming you are on a desktop (not VM) linux installation this should work and get selenium going.

mkdir ~/jasmine-given-test
cd ~/jasmine-given-test
npm install protractor jasmine-given --save-dev
./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start

So you should have selenium running now ... so create another terminal session/console and do:

cd ~/jasmine-given-test
mkdir test
mkdir test/e2e
nano protractor.js

protractor.js

// An example configuration file.
require('coffee-script/register');
require('jasmine-given');

exports.config = {
  // The address of a running selenium server.
  seleniumAddress: 'http://localhost:4444/wd/hub',

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: [
        'test/e2e/*_spec.{js,coffee}'
    ],

  baseUrl: 'http://hello-angularjs.appspot.com/helloworld',

  jasmineNodeOpts: {
    onComplete: function () {},
    isVerbose: false,
    showColors: true,
    includeStackTrace: false,
    defaultTimeoutInterval: 30000
  }
};

Save and Exit

nano test/e2e/test_spec.coffee

test_spec.coffee

describe 'test', ->
  describe 'connect to test site', ->
    Given -> browser.get("/")
    Then -> expect(1).toBe 1

Save and Exit

./node_modules/protractor/bin/protractor ./protractor.js
 TypeError: Object [object Object] has no method 'toHaveReturnedFalseFromThen'
marcelboettcher commented 9 years ago

getting the same error with newest version 2.6.2, coffescript 1.7.1 and protractor 2.0.0

Did you find a solution, @galenp?

Thanks a lot! Marcel