Skip to content

Browser integration tests #1461

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

Merged
merged 14 commits into from
Aug 30, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 52 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ branches:
install: true
sudo: required

node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"

language: node_js
dist: trusty

Expand All @@ -22,17 +13,62 @@ cache:
directories:
- node_modules

script: .travis/script.sh

matrix:
include:
- node_js: "8"
- name: "@sentry/packages - lint"
node_js: "8"
script: .travis/lint.sh
- node_js: "8"
- name: "@sentry/packages - build and test [node v6]"
node_js: "6"
script: .travis/test.sh
- name: "@sentry/packages - build and test [node v7]"
node_js: "7"
script: .travis/test.sh
- name: "@sentry/packages - build and test [node v8]"
node_js: "8"
script: .travis/test.sh
- name: "@sentry/packages - build and test [node v9]"
node_js: "9"
script: .travis/test.sh
- name: "@sentry/packages - build and test [node v10]"
node_js: "10"
script: .travis/test.sh
- name: "@sentry/browser - integration tests"
node_js: "8"
addons:
chrome: stable
firefox: latest
sauce_connect: true
script: .travis/script.sh
exclude:
- node_js: "8"
script: .travis/integration.sh
- name: "raven-js - unit and integration tests"
node_js: "8"
addons:
chrome: stable
firefox: latest
script: .travis/raven-js.sh
- name: "raven-js - saucelabs tests"
node_js: "8"
addons:
sauce_connect: true
script: .travis/raven-js-saucelabs.sh
- name: "raven-node [node v4]"
node_js: "4"
script: .travis/raven-node.sh
- name: "raven-node [node v5]"
node_js: "5"
script: .travis/raven-node.sh
- name: "raven-node [node v6]"
node_js: "6"
script: .travis/raven-node.sh
- name: "raven-node [node v7]"
node_js: "7"
script: .travis/raven-node.sh
- name: "raven-node [node v8]"
node_js: "8"
script: .travis/raven-node.sh
- name: "raven-node [node v9]"
node_js: "9"
script: .travis/raven-node.sh
- name: "raven-node [node v10]"
node_js: "10"
script: .travis/raven-node.sh
25 changes: 0 additions & 25 deletions .travis/before_script.sh

This file was deleted.

36 changes: 36 additions & 0 deletions .travis/detect-raven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e

echo ""
echo "RAVEN: $RAVEN"

# Does any of the commits in a PR contain "[force ci]" string?
COMMITS=$(git --no-pager log master.. --no-merges --format=%s)
if [[ -n "$(grep '\[force ci\]' <<< "$COMMITS")" ]]; then
HAS_FORCE_COMMIT=true
else
HAS_FORCE_COMMIT=false
fi

# echo "COMMITS: $COMMITS"
echo "HAS_FORCE_COMMIT: $HAS_FORCE_COMMIT"

# Does any changed file lives in raven-js/raven-node directory?
CHANGES=$(git --no-pager diff --name-only master)
if [[ -n "$(grep "$RAVEN" <<< "$CHANGES")" ]]; then
HAS_CHANGES=true
else
HAS_CHANGES=false
fi

echo "HAS_CHANGES: $HAS_CHANGES"

# If any of the above is true, run tests
if [[ ( $HAS_FORCE_COMMIT == "true" || $HAS_CHANGES == "true" ) ]]; then
SHOULD_RUN=true
else
SHOULD_RUN=false
fi

echo "SHOULD_RUN: $SHOULD_RUN"

9 changes: 9 additions & 0 deletions .travis/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

yarn
# We have to build other packages first, as we use absolute packages import in TypeScript
yarn build
cd packages/browser
yarn test:integration

23 changes: 4 additions & 19 deletions .travis/lint.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
#!/bin/bash
set -e

source .travis/before_script.sh
yarn
# We have to build it first, so that TypeScript Types are recognized correctly
yarn build
yarn lint

# Run @sentry/*
yarn && yarn build && yarn lint

# Run raven-node
if [[ ("$RAVEN_NODE_CHANGES" = "true" || "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then
cd packages/raven-node
npm install
npm run lint
cd ../..
fi

# Run raven-js
if [[ ("$RAVEN_JS_CHANGES" = "true" || "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then
cd packages/raven-js
npm install
npm run lint
cd ../..
fi
12 changes: 12 additions & 0 deletions .travis/raven-js-saucelabs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

RAVEN="raven-js"
source .travis/detect-raven.sh

if [[ $SHOULD_RUN == "true" ]]; then
cd packages/raven-js
npm install
npm run test:ci
fi

13 changes: 13 additions & 0 deletions .travis/raven-js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

RAVEN="raven-js"
source .travis/detect-raven.sh

if [[ $SHOULD_RUN == "true" ]]; then
cd packages/raven-js
npm install
npm run lint
npm run test
fi

13 changes: 13 additions & 0 deletions .travis/raven-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

RAVEN="raven-node"
source .travis/detect-raven.sh

if [[ $SHOULD_RUN == "true" ]]; then
cd packages/raven-node
npm install
npm run lint
npm run test
fi

32 changes: 0 additions & 32 deletions .travis/script.sh

This file was deleted.

8 changes: 8 additions & 0 deletions .travis/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

yarn
yarn build
yarn test
yarn codecov

52 changes: 52 additions & 0 deletions packages/browser/karma/karma.integration.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = config => {
config.set({
colors: true,
singleRun: true,
autoWatch: false,
basePath: process.cwd(),
files: [
{ pattern: 'test/integration/polyfills/es6-promise-4.2.4.js', included: false },
{ pattern: 'test/integration/polyfills/whatwg-fetch-2.0.4.js', included: false },
{ pattern: 'test/integration/123', included: false },
{ pattern: 'test/integration/throw-string.js', included: false },
{ pattern: 'test/integration/throw-error.js', included: false },
{ pattern: 'test/integration/throw-object.js', included: false },
{ pattern: 'test/integration/example.json', included: false },
{ pattern: 'test/integration/frame.html', included: false },
{ pattern: 'build/bundle.js', included: false },
{ pattern: 'build/bundle.js.map', included: false },
'test/integration/test.js',
],
frameworks: ['mocha', 'chai', 'sinon'],
plugins: [
'karma-mocha',
'karma-mocha-reporter',
'karma-chai',
'karma-sinon',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-failed-reporter',
],
reporters: ['mocha'],
browsers: ['ChromeHeadlessNoSandbox', 'FirefoxHeadless'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-setuid-sandbox'],
},
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless'],
},
},
// https://docs.travis-ci.com/user/gui-and-headless-browsers/#Karma-and-Firefox-inactivity-timeouts
browserNoActivityTimeout: 30000,
concurrency: 2,
client: {
mocha: {
reporter: 'html',
ui: 'bdd',
},
},
});
};
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module.exports = function(config) {
module.exports = config => {
config.set({
colors: true,
singleRun: true,
autoWatch: false,

basePath: process.cwd(),
files: ['test/**/*.ts', 'src/**/*.+(js|ts)'],
frameworks: ['mocha', 'chai', 'sinon', 'karma-typescript'],
browsers: ['ChromeHeadless'],
reporters: ['mocha', 'karma-typescript'],

basePath: process.cwd(),
files: ['test/**/*.ts', 'src/**/*.+(js|ts)'],
preprocessors: {
'**/*.+(js|ts)': ['karma-typescript'],
},

karmaTypescriptConfig: {
tsconfig: 'tsconfig.json',
compilerOptions: {
Expand All @@ -30,7 +27,6 @@ module.exports = function(config) {
'text-summary': '',
},
},

// Uncomment if you want to silence console logs in the output
// client: {
// captureConsole: false,
Expand Down
8 changes: 6 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"karma": "^2.0.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-failed-reporter": "0.0.3",
"karma-firefox-launcher": "^1.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-rollup-preprocessor": "^6.0.0",
Expand Down Expand Up @@ -58,8 +60,10 @@
"fix": "run-s fix:tslint fix:prettier",
"fix:prettier": "prettier --write '{src,test}/**/*.ts'",
"fix:tslint": "tslint --fix -t stylish -p .",
"test": "karma start karma.config.js",
"test:watch": "karma start karma.config.js --auto-watch --no-single-run",
"test": "karma start karma/karma.unit.config.js",
"test:watch": "karma start karma/karma.unit.config.js --auto-watch --no-single-run",
"test:integration": "karma start karma/karma.integration.config.js",
"test:integration:watch": "karma start karma/karma.integration.config.js --auto-watch --no-single-run",
"size:check": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print $1,\"kB\";}'",
"version": "node ../../scripts/versionbump.js src/version.ts"
},
Expand Down
Loading