Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Add npm script to kick off functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adborden committed Jan 24, 2017
1 parent 74fee7e commit 5e1e5a3
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 3 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,29 @@ This project uses CircleCI
- `CONSOLE_API_URL`, `CONSOLE_UAA_URL`, `CONSOLE_LOG_URL`, `CONSOLE_LOGIN_URL`, `CONSOLE_HOSTNAME="http://localhost:9999"`, `CONSOLE_TEST_ORG_NAME`, `CONSOLE_TEST_SPACE_NAME`, and `CONSOLE_TEST_APP_NAME`
- In case you fork this project for your own use (no need to do this if forking to make a pull request), you will need to use the CircleCI CLI UI to set the variables


## Functional Tests

Functional tests are our high-level automated UI tests that are run from the
browser. They can be slow to run, but often catch issues that only appear when
functional components appear together, like when running in a real web browser.

### Prerequisites

The tests are based on Webdriver and use the Selenium Standalone server to drive
the browsers.

- Java 8


### Setup

You'll only have to do this once. This downloads the browser-specific drivers
that we have configured.

$ npm run test-selenium-install


### Run the tests

$ npm run test-functional
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
"check-style": "/bin/bash -c '[[ $(npm ls cloudgov-style) =~ \"git://github.com\" ]] && npm run build-style || exit 0'",
"clean": "rm -rf ./static/assets/*",
"lint": "eslint --ext .js --ext .jsx ./static_src",
"test": "export NODE_ENV=test && npm run lint && karma start --single-run",
"test": "npm run lint && npm run test-karma && npm run test-functional",
"test-functional": "NODE_ENV=test wdio wdio.conf.js",
"test-karma": "NODE_ENV=test karma start --single-run",
"test-selenium-install": "selenium-standalone install --drivers.phantomjs",
"testing-server": "node ./static_src/test/server/server.js",
"watch-server": "npm run testing-server & npm run watch",
"watch-test": "export NODE_ENV=test && karma start --browsers Chrome",
"watch-test": "NODE_ENV=test karma start --browsers Chrome",
"watch": "webpack --watch"
},
"author": "Marco Segreto ([email protected])",
Expand Down Expand Up @@ -101,7 +104,12 @@
"enzyme": "^2.7.0",
"eslint-plugin-jasmine": "^2.2.0",
"jasmine-enzyme": "^2.1.0",
"phantomjs": "^2.1.7",
"react-addons-test-utils": "^15.4.2",
"react-dom": "^15.4.2"
"react-dom": "^15.4.2",
"selenium-standalone": "^5.11.0",
"wdio-jasmine-framework": "^0.2.19",
"wdio-selenium-standalone-service": "0.0.7",
"webdriverio": "^4.6.1"
}
}
File renamed without changes.
7 changes: 7 additions & 0 deletions static_src/test/functional/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../.eslintrc",
"globals": {
"browser": true,
"sinon": true
}
}
28 changes: 28 additions & 0 deletions static_src/test/functional/global_setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable jasmine/no-global-setup */
import testServer from '../server';

// Using promises here to work around this bug https://github.com/webdriverio/wdio-jasmine-framework/issues/28
beforeAll('start test server', function () {
return new Promise((resolve, reject) => {
testServer.start(err => {
if (err) {
return reject(err);
}

return resolve();
});
});
});

afterAll('stop test server', function () {
return new Promise((resolve, reject) => {
const timeout = 5000;
testServer.stop(timeout, err => {
if (err) {
return reject(err);
}

return resolve();
});
});
});
7 changes: 7 additions & 0 deletions static_src/test/functional/overview_quicklook.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

describe('Overview page', function () {
it('navigates to page', function () {
browser.url('http://localhost:8000/');
expect(browser.getTitle()).toBe('cloud.gov dashboard');
});
});
File renamed without changes.
40 changes: 40 additions & 0 deletions wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
exports.config = {
specs: [
'./static_src/test/functional/**/*.spec.js'
],

capabilities: [{
browserName: 'phantomjs'
}],

sync: true,
logLevel: 'error',
coloredLogs: true,

// If you only want to run your tests until a specific amount of tests have failed use
// bail (default is 0 - don't bail, run all tests).
bail: 0,

// Saves a screenshot to a given path if a command fails.
screenshotPath: './screenshots/',

// Set a base URL in order to shorten url command calls. If your url parameter starts
// with "/", then the base url gets prepended.
baseUrl: 'http://localhost:8000',

// Default timeout for all waitFor* commands.
waitforTimeout: 10000,

// Default timeout in milliseconds for request
// if Selenium Grid doesn't send response
connectionRetryTimeout: 90000,

// Default request retries count
connectionRetryCount: 3,

services: ['selenium-standalone'],
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 10000
}
};

0 comments on commit 5e1e5a3

Please sign in to comment.