2
votes

I'm working on switching our Unit/Functional test framework to Intern, but all the different configurations I've tried result in Intern running only the unit tests and not picking up the functional tests at all.

Selenium Standalone and ChromeDriver are indeed running at port 4444.

I've got a configuration file that looks as follows:

// Learn more about configuring this file at <https://github.com/theintern/intern/wiki/Configuring-Intern>.
// These default settings work OK for most people. The options that *must* be changed below are the
// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites.
define({
    // The port on which the instrumenting proxy will listen
    proxyPort: 9000,

    // A fully qualified URL to the Intern proxy
    proxyUrl: 'http://localhost:9000/',

    // Default desired capabilities for all environments. Individual capabilities can be overridden by any of the
    // specified browser environments in the `environments` array below as well. See
    // https://code.google.com/p/selenium/wiki/DesiredCapabilities for standard Selenium capabilities and
    // https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities.
    // Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
    // automatically
    capabilities: {
        'selenium-version': '2.44.0'
    },

    // Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
    // OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
    // capabilities options specified for an environment will be copied as-is
    environments: [
    { browserName: 'chrome' }
    ],

    // Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
    maxConcurrency: 3,

    // Name of the tunnel class to use for WebDriver tests
    tunnel: 'NullTunnel',

    // The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo
    // loader
    useLoader: {
    'host-node': 'requirejs',
    'host-browser': '../../node_modules/requirejs/require.js'
  },

  reporters: ['pretty'],

    // Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader
    // can be used here
    loader: {
        // Packages that should be registered with the loader in each testing environment
        packages: [
      { name: 'controls', location: './js' },
      { name: 'jquery', location: './node_modules/jquery' }
    ]
    },

  // Turn off connection to Sauce Labs
  useSauceConnect: false,

  // Setup for Selenium Webdriver
  webdriver: {
    host: 'localhost',
    port: 4444
  },

    // Non-functional test suite(s) to run in each browser
    suites: [ 'intern-test/unit/_all' ],

    // Functional test suite(s) to run in each browser once non-functional tests are completed
    functionalSuites: [ 'intern-test/functional/_all' ],

    // A regular expression matching URLs to files that should not be included in code coverage analysis
    excludeInstrumentation: /^(?:test|intern-test|node_modules)\//
});

the unit and functional test suites ('_all.js') are basically just loading all the individual test modules in one place, like so:

define([
  './module-one-unit-tests',
], function () {
  // This is just used for loading up all tests at once
  console.log('loaded unit tests');
});



define([
  './module-one-functional-tests',
], function () {
  // This is just used for loading up all tests at once
  console.log('loaded functional tests');
});

I've got a unit test that looks like this:

define([
  'require'
], function(require) {

  var registerSuite = require('intern!object'),
    expect = require('intern/chai!expect');

  console.log('multiselect tests loaded');

  registerSuite({
    name: 'Multiselect (unit)',

    'passing test': function() {
      var str = '';
      expect(str).to.equal('');
    }

  });

  console.log('registered multiselect tests');

});

And a functional test that looks like this:

define([
  'require'
], function (require) {

  var url = 'http://localhost:4000/tests/multiselect',
    registerSuite =   require('intern!object'),
    expect = require('intern/chai!expect'),
    Keys = require('intern/node_modules/leadfoot/keys');

  function addIds() {
    $('#states-multi-shdo').prev().attr('id', 'states-multi-textbox');
    $('#towns-multi-optgroup-shdo').prev().attr('id', 'towns-multi-optgroup-textbox');
    $('#fruits-multi-shdo').prev().attr('id', 'fruits-multi-textbox');
  }

  function getMultiSelectVal(selector) {
    return $(selector).val();
  }

  var STATES = 'states-multi',
    STATES_TEXTBOX = 'states-multi-textbox',
    FRUITS_TEXTBOX = 'fruits-multi-textbox',
    DDLIST = 'dropdown-list';

  registerSuite({
    name: 'Multiselect (functional)',

    setup: function() {
      return this.remote
        .get(require.toUrl(url))
        .setWindowSize(null, 1024, 768)
        .execute(addIds)
        .sleep(100);
    },

    'will not allow more than the "data-maxselected" attribute\'s specified number of selected options in the list': function () {
      return this.remote
        .findById(STATES_TEXTBOX)
          .click()
          .pressKeys([
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.SPACE, Keys.ARROW_DOWN,
            Keys.ESCAPE
          ])
          .end()
        .findById(STATES)
          .getProperty('selectedOptions')
          .then(function (val) {
            console.log(val);
            expect(val.length).to.equal(10);
          });
    }

  });
});

As I said, when I fire the test runner using node_modules/.bin/intern-client config=intern-test/intern.local, the unit tests run perfectly fine, but the functional tests are nowhere to be found.

I've scoured the Intern Documentation on Functional Testing and Common Configuration several times, and I can't seem to figure out where I might be going wrong.

Can anyone tell me how I've screwed this up?

1

1 Answers

7
votes

intern-client is the Node.js client and only runs unit tests in Node.js. intern-runner is the test runner that will execute unit & functional tests against a remote browser. You need to use intern-runner, not intern-client.