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

Replace phantomjs with Chrome #476

Merged
merged 5 commits into from Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions .travis.yml
@@ -1,9 +1,22 @@
# Environment
sudo: false
dist: trusty
language: node_js
node_js:
- 4

env:
- TEST_SUITE=main
- TEST_SUITE=tz TZ_LENGTH=2 TZ_INDEX=0
- TEST_SUITE=tz TZ_LENGTH=2 TZ_INDEX=1
# TODO: Enable when SauceLabs become reliable
# - TEST_SUITE=cross_browser

before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

branches:
only:
- master
Expand All @@ -12,15 +25,7 @@ branches:

# Tests
script:
- yarn run lint
- yarn run flow-check
- yarn run systemjs-check
- yarn run test-ci
- # TODO: Enable when SauceLabs become reliable
- # '[ "${SAUCE_USERNAME}" = "" ] || yarn run test-cross-browser'
- yarn run test-tz
- yarn run test-tz-extended
- yarn run count-tests
- yarn run test-travis

# Deployment
before_deploy:
Expand Down
14 changes: 10 additions & 4 deletions config/karma.js
@@ -1,4 +1,3 @@
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs'
process.env.NODE_ENV = 'test'

var webpackConfig = require('./webpack')
Expand Down Expand Up @@ -83,6 +82,13 @@ var sauceLabsLaunchers = {
}
}

var travisLaunchers = {
ChromeTravis: {
base: 'Chrome',
flags: ['--no-sandbox', '--no-default-browser-check', '--no-first-run', '--disable-default-apps']
}
}

function config (config) {
config.set({
frameworks: getFrameworksConfig(),
Expand Down Expand Up @@ -124,7 +130,7 @@ function config (config) {
'karma-es5-shim',
'karma-mocha',
'karma-mocha-reporter',
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-sauce-launcher',
'karma-sinon',
'karma-sourcemap-loader',
Expand All @@ -135,8 +141,8 @@ function config (config) {
{'reporter:benchmark-json': ['type', benchmarkJSONReporter]}
],

customLaunchers: process.env.TEST_CROSS_BROWSER ? sauceLabsLaunchers : {},
browsers: process.env.TEST_CROSS_BROWSER ? Object.keys(sauceLabsLaunchers) : ['PhantomJS'],
customLaunchers: process.env.TEST_CROSS_BROWSER ? sauceLabsLaunchers : travisLaunchers,
browsers: Object.keys(process.env.TEST_CROSS_BROWSER ? sauceLabsLaunchers : travisLaunchers),
reporters: getReportersConfig()
})
}
Expand Down
2 changes: 1 addition & 1 deletion config/webpack.js
Expand Up @@ -16,7 +16,7 @@ var config = {
function getEntryConfig () {
if (process.env.BUILD_TESTS) {
return {
'tests': './test.js'
'tests': './testWithoutLocales.js'
}
} else if (process.env.NODE_ENV === 'test') {
return {}
Expand Down
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -24,11 +24,11 @@
"karma": "^1.3.0",
"karma-benchmark": "^0.6.0",
"karma-benchmark-reporter": "^0.1.1",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-es5-shim": "0.0.4",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sauce-launcher": "^0.3.0",
"karma-sinon": "^1.0.4",
"karma-sourcemap-loader": "^0.3.5",
Expand All @@ -52,6 +52,7 @@
"test": "karma start config/karma.js",
"test-ci": "npm test -- --single-run",
"test-cross-browser": "env TEST_CROSS_BROWSER=true npm test -- --single-run",
"test-travis": "./scripts/test_travis.sh",
"test-tz": "yarn run build-tests && ./scripts/test_tz.sh",
"test-tz-extended": "yarn run build-tests && ./scripts/test_tz_extended.sh",
"count-tests": "./scripts/count_tests.sh",
Expand Down Expand Up @@ -80,6 +81,8 @@
},
"standard": {
"parser": "babel-eslint",
"ignore": ["dist/"]
"ignore": [
"dist/"
]
}
}
3 changes: 3 additions & 0 deletions scripts/count_tests.sh
@@ -1,5 +1,8 @@
#!/bin/bash

count=$( cat tmp/tests_count.txt 2> /dev/null || echo 0 )

printf "\n%bSUITE: %s%b\n" "\x1B[32m" "$TEST_SUITE" "\x1B[0m"
printf "\n%bTOTAL TESTS COMPLETED: %s%b\n" "\x1B[32m" "$count" "\x1B[0m"

rm -f tmp/tests_count.txt
23 changes: 23 additions & 0 deletions scripts/test_travis.sh
@@ -0,0 +1,23 @@
#!/bin/bash

if [ "$TEST_SUITE" == "main" ]
then
yarn run lint || exit 1
yarn run flow-check || exit 1
yarn run systemjs-check || exit 1
yarn run test-ci || exit 1
yarn run test-tz || exit 1

elif [ "$TEST_SUITE" == "tz" ]
then
yarn run test-tz-extended || exit 1

elif [ $TEST_SUITE == "cross_browser" ] && [ "$SAUCE_USERNAME" != "" ]
then
yarn run test-cross-browser || exit 1

else
printf "\n\033[0;31m" "UNKNOWN SUITE!" "\033[0m\n"
fi

yarn run count-tests
2 changes: 1 addition & 1 deletion scripts/test_tz.sh
Expand Up @@ -11,6 +11,6 @@ for tz in UTC-12:00 UTC-11:00 UTC-10:00 UTC-09:30 UTC-09:00 \
UTC+11:30 UTC+12:00 UTC+12:45 UTC+13:00 UTC+14:00
do
printf "Run test in time zone $tz\n"
env TEST_TZ=true USE_STATIC_TESTS=true TZ=$tz npm run test-ci \
env TEST_TZ=true USE_STATIC_TESTS=true TZ=$tz yarn run test-ci \
&>tmp/last_test_output.txt || (cat tmp/last_test_output.txt && exit 1) || exit 1
done