The Intern javascript Tests

Has anyone successfully used theintern.github.io/intern on CircleCI. If so could you share how?

my circle.yml

machine:
  node:
    version: 5.6.0

  environment:
    IN_CI: 1
    NODE_ENV: production
    SELENIUM_HOST: hub.browserstack.com
    SELENIUM_PORT: 80
    BS_AUTOMATE_PROJECT: "Run on circleCI"
    BS_AUTOMATE_BUILD: "build No. $CIRCLE_BUILD_NUM for circleCI"
    SELENIUM_PLATFORM: WINDOWS
    SELENIUM_BROWSER: IE
    SELENIUM_VERSION: 9

test:
  pre:
    - npm run build:webpack:dev
    - wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_linux32.zip
    - unzip chromedriver_linux32.zip
    - ./chromedriver --port=4444 --url-base=we/hub &
  override:
    - npm test
```

my package.json
```
{
  "scripts": {
    "test": "node ./node_modules/.bin/intern-runner config=tests/intern.js"
  }
}
```

my config tests/intern.js
```
define({
	capabilities: {
		'browserstack.selenium_version': '2.45.0'
	},
	environments: [
		// { browserName: 'internet explorer', version: '11', platform: 'WIN8' },
		// { browserName: 'internet explorer', version: '10', platform: 'WIN8' },
		// { browserName: 'internet explorer', version: '9', platform: 'WINDOWS' },
		// { browserName: 'firefox', version: '37', platform: [ 'WINDOWS', 'MAC' ] },
		{ browserName: 'chrome', version: '39', platform: [ 'WINDOWS', 'MAC' ] }
		// { browserName: 'safari', version: '8', platform: 'MAC' }
	],
	maxConcurrency: 2,
	tunnel: 'NullTunnel',
	loaderOptions: {
		packages: [ { name: 'myPackage', location: '.' } ]
	},
	suites: [ /* 'myPackage/tests/foo', 'myPackage/tests/bar' */ ],
	functionalSuites: [ /* 'myPackage/tests/functional' */ ],
	excludeInstrumentation: /^(?:tests|node_modules)\//
});
```

note I'm using the `NullTunnel` as I'd like CircleCI to run the tests until I'm ready to pay for browserstack or saucelabs.

I get the following error
```
npm test

> @project
> node ./node_modules/.bin/intern-runner config=tests/intern.js


> @project
> node ./node_modules/.bin/intern-runner config=tests/intern.js

Listening on 0.0.0.0:9000
Listening on 0.0.0.0:9000
Tunnel started
Suite chrome 39 on WINDOWS FAILED
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED 127.0.0.1:4444
  at Server.createSession  <node_modules/leadfoot/Server.js:324:15>
  at <node_modules/intern/lib/executors/Runner.js:191:22>
  at retry  <node_modules/intern/lib/util.js:845:13>
  at <node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/dojo/Promise.ts:11:11>
  at <node_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/dojo/Promise.ts:237:7>
  at <node_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>
Suite chrome 39 on MAC FAILED
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED 127.0.0.1:4444
  at Server.createSession  <node_modules/leadfoot/Server.js:324:15>
  at <node_modules/intern/lib/executors/Runner.js:191:22>
  at retry  <node_modules/intern/lib/util.js:845:13>
  at <node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/dojo/Promise.ts:11:11>
  at <node_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/dojo/Promise.ts:237:7>
  at <node_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>

TOTAL: tested 0 platforms, 0/0 tests failed; fatal error occurred
Tunnel started
Suite chrome 39 on WINDOWS FAILED
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED 127.0.0.1:4444
  at Server.createSession  <node_modules/leadfoot/Server.js:324:15>
  at <node_modules/intern/lib/executors/Runner.js:191:22>
  at retry  <node_modules/intern/lib/util.js:845:13>
  at <node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/dojo/Promise.ts:11:11>
  at <node_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/dojo/Promise.ts:237:7>
  at <node_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>
Suite chrome 39 on MAC FAILED
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED 127.0.0.1:4444
  at Server.createSession  <node_modules/leadfoot/Server.js:324:15>
  at <node_modules/intern/lib/executors/Runner.js:191:22>
  at retry  <node_modules/intern/lib/util.js:845:13>
  at <node_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/dojo/Promise.ts:11:11>
  at <node_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/dojo/Promise.ts:237:7>
  at <node_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>

TOTAL: tested 0 platforms, 0/0 tests failed; fatal error occurred
Error: Run failed due to one or more suite errors
  at emitLocalCoverage  <node_modules/intern/lib/executors/Executor.js:353:18>
  at finishSuite  <node_modules/intern/lib/executors/Executor.js:370:15>
  at <node_modules/intern/lib/executors/Executor.js:378:8>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/intern/browser_modules/dojo/Promise.ts:11:11>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/intern/browser_modules/dojo/Promise.ts:237:7>
  at <node_modules/intern/browser_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>
npm ERR! Test failed.  See above for more details.
Error: Run failed due to one or more suite errors
  at emitLocalCoverage  <node_modules/intern/lib/executors/Executor.js:353:18>
  at finishSuite  <node_modules/intern/lib/executors/Executor.js:370:15>
  at <node_modules/intern/lib/executors/Executor.js:378:8>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/intern/browser_modules/dojo/Promise.ts:11:11>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/intern/browser_modules/dojo/Promise.ts:237:7>
  at <node_modules/intern/browser_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>
npm ERR! Test failed.  See above for more details.

npm test returned exit code 1
npm test returned exit code 1
```
doesn't seem able to connect to the chromedriver

Made some progress moved the driver installation step to dependencies#post

#circle.yml
dependencies:
  override:
    - NODE_ENV=development npm install
  post:
    - wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    - ./chromedriver --port=4444 --url-base=wd/hub:
        background: true
test:
  pre:
    - npm start:
        background: true
  override:
    - npm test

changed the config environment to linux and used the 64-bit driver. I also start the main javascript project in the background.

//tests/intern.js
{ browserName: 'chrome', version: '50', platform: [ 'Linux' ] }
...
functionalSuites: [ 'tests/functional/index' ],

Ensured I was using Ubuntu 14.04 as opposed to the current default 12.04. Bumped the chrome version to 50 to match the installed version on 14.04. I also specify where I put the functional tests.

An example functional test could look like

// tests/functional/index.js
define(function (require) {
    var registerSuite = require('intern!object');
    var assert = require('intern/chai!assert');

    registerSuite({
        name: 'Sign In Page',

        'has Sign In button': function () {
          return this.remote
            .get('http://localhost:3000/login')
            .setFindTimeout(5000)
            .find('xpath', '//*')
            .getVisibleText()
            .then(function(text) {
              assert.include(text, 'SIGN IN', 'Page contains \'Sign In\' button');
            });
        }
    });
});

Works for me :+1:

around January 18th 2017 my tests were failing like so
> node ./node_modules/.bin/intern-runner config=tests/intern.js
Listening on 0.0.0.0:9000
Tunnel started
Suite chrome 50 on Linux FAILED
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED 127.0.0.1:4444
at Server.createSession <node_modules/leadfoot/Server.js:355:15>
at <node_modules/intern/lib/executors/Runner.js:198:23>
at retry <node_modules/intern/lib/util.js:818:13>
at <node_modules/dojo/Promise.ts:393:15>
at runCallbacks <node_modules/dojo/Promise.ts:11:11>
at <node_modules/dojo/Promise.ts:317:4>
at run <node_modules/dojo/Promise.ts:237:7>
at <node_modules/dojo/nextTick.ts:44:3>
at nextTickCallbackWith0Args node.js:453:9
at process._tickCallback node.js:382:13

TOTAL: tested 0 platforms, 0/0 tests failed; fatal error occurred

Error: Run failed due to one or more suite errors
  at emitLocalCoverage  <node_modules/intern/lib/executors/Executor.js:363:18>
  at finishSuite  <node_modules/intern/lib/executors/Executor.js:380:15>
  at <node_modules/intern/lib/executors/Executor.js:388:8>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:393:15>
  at runCallbacks  <node_modules/intern/browser_modules/dojo/Promise.ts:11:11>
  at <node_modules/intern/browser_modules/dojo/Promise.ts:317:4>
  at run  <node_modules/intern/browser_modules/dojo/Promise.ts:237:7>
  at <node_modules/intern/browser_modules/dojo/nextTick.ts:44:3>
  at nextTickCallbackWith0Args  <node.js:453:9>
  at process._tickCallback  <node.js:382:13>
npm ERR! Test failed.  See above for more details.

I fixed it by updating the version of the chromedriver I was using to 2.27

#circle.yml   
  - wget http://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip