How to use Jasmine and CucumberJS with Protractor

502 views
Skip to first unread message

aristark...@gmail.com

unread,
Jun 11, 2015, 4:42:48 PM6/11/15
to cu...@googlegroups.com
I'm looking to use Protractor, CucumberJS, and Jasmine for testing my project. How do I use both Jasmine and CucumberJS with Protractor? Here's the project setup I've created:

/path/to/myproj/**protractor.conf.js**

    exports.config = {
      seleniumServerJar: 'node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
    
      specs: [
        'features/*.feature'
      ],
      
      baseUrl: 'http://localhost:8080',
      
      multiCapabilities: [
        {
          'browserName': 'chrome'
        }
      ],
      
      allScriptsTimeout: 380000,
      getPageTimeout: 20000,
    
      framework: 'cucumber',
    
      cucumberOpts: {
        require: 'features/stepDefinitions.js',
        format: 'summary'
      }
    };

As you can see, this project uses "cucumber" as the framework. How do I add in the Jasmine framework alongside CucumberJS? Would this be through the Protractor configuration file or someplace else in the code?

/path/to/myproj/**features/demo.feature**

    Feature: Some terse yet descriptive text of what is desired
    
      Scenario: Some determinable business situation
        Given some precondition

/path/to/myproj/**features/stepDefinitions.js**

    module.exports = function() {
      this.Given(/^some precondition$/, function (callback) {
        expect(true).toEqual(true);
        callback();
      });
    };

When this is executed, "expect" is not defined, presumably because Jasmine has not been integrated, and it's expect global along with it. Here's the full error message:

    $ $(npm bin)/protractor protractor.conf.js 
    Starting selenium standalone server...
    [launcher] Running 1 instances of WebDriver
    Selenium standalone server started at http://192.168.1.115:59957/wd/hub
    (::) failed steps (::)
    
    ReferenceError: expect is not defined
      at World.<anonymous> (/path/to/myproj/features/stepDefinitions.js:3:5)
      at process._tickCallback (node.js:355:11)
    
    
    Failing scenarios:
    /path/to/myproj/features/demo.feature:3 # Scenario: Some determinable business situation
    
    1 scenario (1 failed)
    1 step (1 failed)
    Shutting down selenium standalone server.
    [launcher] 0 instance(s) of WebDriver still running
    [launcher] chrome #1 failed 1 test(s)
    [launcher] overall: 1 failed spec(s)
    [launcher] Process exited with error code 1

/path/to/myproj/**package.json**

    {
      "name": "myproj",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "cucumber": "0.4.9",
      }
    }

Note: I'm using a particular commit to the Protractor Git repository in my package.json, because the latest version (2.1.0) has [a bug][1], which prevents integration with CucumberJS.


Julien Biezemans

unread,
Jun 11, 2015, 4:54:29 PM6/11/15
to cu...@googlegroups.com
On Thu, Jun 11, 2015 at 10:42 PM <aristark...@gmail.com> wrote:
I'm looking to use Protractor, CucumberJS, and Jasmine for testing my project. How do I use both Jasmine and CucumberJS with Protractor?

You need to ask the Protractor folks about this: https://github.com/angular/protractor#getting-help

I *think* you'll need two Protractor setups, one for Cucumber, the other for Jasmine.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages