Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: functional test framework using CodeceptJS #628

Merged
merged 8 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ reports
dist
src/i18n/json
jsconfig.json
functional-tests/output
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '6'
- '8'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any repercussions from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremypress we will have to update to node 8, which is pretty widely adopted at Box. I have also been using node 8 for the past few days and it has been fine.

stages:
- ci
- name: sauce-labs
Expand Down
60 changes: 60 additions & 0 deletions codecept.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const DEFAULT_WAIT_TIME = 10000; // 10 seconds
const {
SAUCE_USERNAME,
SAUCE_ACCESS_KEY,
TRAVIS_JOB_NUMBER,
CI,
BROWSER_NAME = 'chrome',
BROWSER_VERSION = 'latest',
BROWSER_PLATFORM
} = process.env;

// Local selenium config
const webDriverIOlocal = {
url: 'http://localhost:8000',
browser: 'chrome',
smartWait: DEFAULT_WAIT_TIME,
restart: false,
waitForTimeout: DEFAULT_WAIT_TIME
};

// CI saucelabs config
const WebDriverIO =
typeof SAUCE_USERNAME === 'undefined'
? webDriverIOlocal
: Object.assign({}, webDriverIOlocal, {
host: 'ondemand.saucelabs.com',
port: 80,
user: SAUCE_USERNAME,
key: SAUCE_ACCESS_KEY,
desiredCapabilities: {
'tunnel-identifier': TRAVIS_JOB_NUMBER,
browserName: BROWSER_NAME,
version: BROWSER_VERSION,
platform: BROWSER_PLATFORM,
chromeOptions: {
args: ['--disable-web-security']
}
}
});

// Local saucelabs config
if (!CI) {
Object.assign(WebDriverIO, {
host: 'localhost',
port: 4445
});
}

exports.config = {
tests: './functional-tests/*_test.js',
timeout: DEFAULT_WAIT_TIME,
output: './functional-tests/output',
helpers: {
WebDriverIO
},
include: {},
bootstrap: false,
mocha: {},
name: 'box-content-preview'
};
10 changes: 10 additions & 0 deletions functional-tests/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"../.eslintrc"
],
"globals": {
"Feature" : false,
"Before" : false,
"Scenario" : false
}
}
11 changes: 11 additions & 0 deletions functional-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Running tests locally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯


## Saucelabs
1) Download the [saucelabs proxy](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy)
2) Run ```yarn functional-tests``` to start a local server on localhost:8000
3) Run the proxy ```./bin/sc -u SAUCELABS_USER_NAME -k SAUCELABS_ACCESS_KEY -N -i test``` to allow saucelabs to access your localhost
4) Run the tests
```SAUCE_USERNAME=SAUCELABS_USER_NAME SAUCE_ACCESS_KEY=SAUCELABS_ACCESS_KEY TRAVIS_JOB_NUMBER=TUNNEL_ID node ./node_modules/codeceptjs/bin/codecept.js run --verbose``` where SAUCE_USERNAME, SAUCELABS_ACCESS_KEY can be found in saucelabs website. TUNNEL_ID is a unique identifier such as your username.

## local selenium and browser testing (without saucelabs)
Make sure selenium webdriver is running and run ```node ./node_modules/codeceptjs/bin/codecept.js run --verbose```
53 changes: 0 additions & 53 deletions functional-tests/base-test.js

This file was deleted.

12 changes: 12 additions & 0 deletions functional-tests/sanity_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature('Sanity');
const bpLoaded = '.bp-loaded';

Before((I) => {
I.amOnPage('/functional-tests/index.html');
});

Scenario('Sanity test @ci', (I) => {
I.waitForElement(bpLoaded);
I.waitForVisible(bpLoaded);
I.waitForText('The Content Platform for Your Apps');
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"box-annotations": "^0.11.1",
"chai": "^4.1.2",
"chai-dom": "^1.5.0",
"codeceptjs-webdriverio": "^1.1.0",
"conventional-changelog-cli": "^1.3.5",
"conventional-github-releaser": "^2.0.0",
"create-react-class": "^15.6.2",
Expand Down Expand Up @@ -104,8 +105,8 @@
"commitmsg": "commitlint -e",
"debug": "NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js --no-single-run --auto-watch",
"dev": "BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --progress --colors --config build/webpack.config.js",
"functional-tests": "python -m SimpleHTTPServer 8000 & node ./node_modules/mocha/bin/mocha --recursive ./functional-tests/ --timeout 10000 ; killall python -m SimpleHTTPServer 8000",
"functional-tests-ci": "yarn run clean && yarn run build-rb && yarn run build-ci && node ./node_modules/mocha/bin/mocha ./functional-tests/ --timeout 10000",
"functional-tests": "python -m SimpleHTTPServer 8000 & node ./node_modules/codeceptjs/bin/codecept.js run --verbose ; killall python -m SimpleHTTPServer 8000",
"functional-tests-ci": "yarn run clean && yarn run build-rb && yarn run build-ci && node ./node_modules/codeceptjs/bin/codecept.js run --verbose --grep @ci",
"lint": "NODE_ENV=dev ./node_modules/.bin/eslint src/lib && ./node_modules/.bin/stylelint 'src/lib/**/*.scss'",
"precommit": "lint-staged",
"prepush": "yarn run lint",
Expand Down
Loading