Skip to content

Commit 1f3bdca

Browse files
kamilogorekHazAT
authored andcommitted
feat: Browser integration tests (#1461)
* browser: Ported and updated integration tests setup (no tests fixed yet) * test: Update karma config for integration tests * utils: Fixed parseUrl and serializeObject methods * browser: Fixed event creation based on the type * browser: Filter out our own requests from breadcrumb integrations * browser: Fixed ignoreNextOnError * browser: Fixed mechanism for wrapped functions and eventFromObject thingy * tracekit: onerror url patch for Firefox * browser: Ported all integration tests from raven-js * test: Rework travis jobs * test: Dedupe integration and fixed remaining integration tests * fix: Restore attachStacktrace option * build: Add missing HeadlessChrome extension to packages/browser jobs * Travis wasnt the issue, it was message deduping
1 parent bdbb979 commit 1f3bdca

40 files changed

+3627
-218
lines changed

.travis.yml

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ branches:
55
install: true
66
sudo: required
77

8-
node_js:
9-
- "4"
10-
- "5"
11-
- "6"
12-
- "7"
13-
- "8"
14-
- "9"
15-
- "10"
16-
178
language: node_js
189
dist: trusty
1910

@@ -22,17 +13,62 @@ cache:
2213
directories:
2314
- node_modules
2415

25-
script: .travis/script.sh
26-
2716
matrix:
2817
include:
29-
- node_js: "8"
18+
- name: "@sentry/packages - lint"
19+
node_js: "8"
3020
script: .travis/lint.sh
31-
- node_js: "8"
21+
- name: "@sentry/packages - build and test [node v6]"
22+
node_js: "6"
23+
script: .travis/test.sh
24+
- name: "@sentry/packages - build and test [node v7]"
25+
node_js: "7"
26+
script: .travis/test.sh
27+
- name: "@sentry/packages - build and test [node v8]"
28+
node_js: "8"
29+
script: .travis/test.sh
30+
- name: "@sentry/packages - build and test [node v9]"
31+
node_js: "9"
32+
script: .travis/test.sh
33+
- name: "@sentry/packages - build and test [node v10]"
34+
node_js: "10"
35+
script: .travis/test.sh
36+
- name: "@sentry/browser - integration tests"
37+
node_js: "8"
3238
addons:
3339
chrome: stable
3440
firefox: latest
3541
sauce_connect: true
36-
script: .travis/script.sh
37-
exclude:
38-
- node_js: "8"
42+
script: .travis/integration.sh
43+
- name: "raven-js - unit and integration tests"
44+
node_js: "8"
45+
addons:
46+
chrome: stable
47+
firefox: latest
48+
script: .travis/raven-js.sh
49+
- name: "raven-js - saucelabs tests"
50+
node_js: "8"
51+
addons:
52+
sauce_connect: true
53+
script: .travis/raven-js-saucelabs.sh
54+
- name: "raven-node [node v4]"
55+
node_js: "4"
56+
script: .travis/raven-node.sh
57+
- name: "raven-node [node v5]"
58+
node_js: "5"
59+
script: .travis/raven-node.sh
60+
- name: "raven-node [node v6]"
61+
node_js: "6"
62+
script: .travis/raven-node.sh
63+
- name: "raven-node [node v7]"
64+
node_js: "7"
65+
script: .travis/raven-node.sh
66+
- name: "raven-node [node v8]"
67+
node_js: "8"
68+
script: .travis/raven-node.sh
69+
- name: "raven-node [node v9]"
70+
node_js: "9"
71+
script: .travis/raven-node.sh
72+
- name: "raven-node [node v10]"
73+
node_js: "10"
74+
script: .travis/raven-node.sh

.travis/before_script.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

.travis/detect-raven.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo ""
5+
echo "RAVEN: $RAVEN"
6+
7+
# Does any of the commits in a PR contain "[force ci]" string?
8+
COMMITS=$(git --no-pager log master.. --no-merges --format=%s)
9+
if [[ -n "$(grep '\[force ci\]' <<< "$COMMITS")" ]]; then
10+
HAS_FORCE_COMMIT=true
11+
else
12+
HAS_FORCE_COMMIT=false
13+
fi
14+
15+
# echo "COMMITS: $COMMITS"
16+
echo "HAS_FORCE_COMMIT: $HAS_FORCE_COMMIT"
17+
18+
# Does any changed file lives in raven-js/raven-node directory?
19+
CHANGES=$(git --no-pager diff --name-only master)
20+
if [[ -n "$(grep "$RAVEN" <<< "$CHANGES")" ]]; then
21+
HAS_CHANGES=true
22+
else
23+
HAS_CHANGES=false
24+
fi
25+
26+
echo "HAS_CHANGES: $HAS_CHANGES"
27+
28+
# If any of the above is true, run tests
29+
if [[ ( $HAS_FORCE_COMMIT == "true" || $HAS_CHANGES == "true" ) ]]; then
30+
SHOULD_RUN=true
31+
else
32+
SHOULD_RUN=false
33+
fi
34+
35+
echo "SHOULD_RUN: $SHOULD_RUN"
36+

.travis/integration.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
yarn
5+
# We have to build other packages first, as we use absolute packages import in TypeScript
6+
yarn build
7+
cd packages/browser
8+
yarn test:integration
9+

.travis/lint.sh

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
#!/bin/bash
22
set -e
33

4-
source .travis/before_script.sh
4+
yarn
5+
# We have to build it first, so that TypeScript Types are recognized correctly
6+
yarn build
7+
yarn lint
58

6-
# Run @sentry/*
7-
yarn && yarn build && yarn lint
8-
9-
# Run raven-node
10-
if [[ ("$RAVEN_NODE_CHANGES" = "true" || "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then
11-
cd packages/raven-node
12-
npm install
13-
npm run lint
14-
cd ../..
15-
fi
16-
17-
# Run raven-js
18-
if [[ ("$RAVEN_JS_CHANGES" = "true" || "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then
19-
cd packages/raven-js
20-
npm install
21-
npm run lint
22-
cd ../..
23-
fi

.travis/raven-js-saucelabs.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RAVEN="raven-js"
5+
source .travis/detect-raven.sh
6+
7+
if [[ $SHOULD_RUN == "true" ]]; then
8+
cd packages/raven-js
9+
npm install
10+
npm run test:ci
11+
fi
12+

.travis/raven-js.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RAVEN="raven-js"
5+
source .travis/detect-raven.sh
6+
7+
if [[ $SHOULD_RUN == "true" ]]; then
8+
cd packages/raven-js
9+
npm install
10+
npm run lint
11+
npm run test
12+
fi
13+

.travis/raven-node.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RAVEN="raven-node"
5+
source .travis/detect-raven.sh
6+
7+
if [[ $SHOULD_RUN == "true" ]]; then
8+
cd packages/raven-node
9+
npm install
10+
npm run lint
11+
npm run test
12+
fi
13+

.travis/script.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

.travis/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
yarn
5+
yarn build
6+
yarn test
7+
yarn codecov
8+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = config => {
2+
config.set({
3+
colors: true,
4+
singleRun: true,
5+
autoWatch: false,
6+
basePath: process.cwd(),
7+
files: [
8+
{ pattern: 'test/integration/polyfills/es6-promise-4.2.4.js', included: false },
9+
{ pattern: 'test/integration/polyfills/whatwg-fetch-2.0.4.js', included: false },
10+
{ pattern: 'test/integration/123', included: false },
11+
{ pattern: 'test/integration/throw-string.js', included: false },
12+
{ pattern: 'test/integration/throw-error.js', included: false },
13+
{ pattern: 'test/integration/throw-object.js', included: false },
14+
{ pattern: 'test/integration/example.json', included: false },
15+
{ pattern: 'test/integration/frame.html', included: false },
16+
{ pattern: 'build/bundle.js', included: false },
17+
{ pattern: 'build/bundle.js.map', included: false },
18+
'test/integration/test.js',
19+
],
20+
frameworks: ['mocha', 'chai', 'sinon'],
21+
plugins: [
22+
'karma-mocha',
23+
'karma-mocha-reporter',
24+
'karma-chai',
25+
'karma-sinon',
26+
'karma-chrome-launcher',
27+
'karma-firefox-launcher',
28+
'karma-failed-reporter',
29+
],
30+
reporters: ['mocha'],
31+
browsers: ['ChromeHeadlessNoSandbox', 'FirefoxHeadless'],
32+
customLaunchers: {
33+
ChromeHeadlessNoSandbox: {
34+
base: 'ChromeHeadless',
35+
flags: ['--no-sandbox', '--disable-setuid-sandbox'],
36+
},
37+
FirefoxHeadless: {
38+
base: 'Firefox',
39+
flags: ['-headless'],
40+
},
41+
},
42+
// https://docs.travis-ci.com/user/gui-and-headless-browsers/#Karma-and-Firefox-inactivity-timeouts
43+
browserNoActivityTimeout: 30000,
44+
concurrency: 2,
45+
client: {
46+
mocha: {
47+
reporter: 'html',
48+
ui: 'bdd',
49+
},
50+
},
51+
});
52+
};

packages/browser/karma.config.js renamed to packages/browser/karma/karma.unit.config.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
module.exports = function(config) {
1+
module.exports = config => {
22
config.set({
33
colors: true,
44
singleRun: true,
55
autoWatch: false,
6-
6+
basePath: process.cwd(),
7+
files: ['test/**/*.ts', 'src/**/*.+(js|ts)'],
78
frameworks: ['mocha', 'chai', 'sinon', 'karma-typescript'],
89
browsers: ['ChromeHeadless'],
910
reporters: ['mocha', 'karma-typescript'],
10-
11-
basePath: process.cwd(),
12-
files: ['test/**/*.ts', 'src/**/*.+(js|ts)'],
1311
preprocessors: {
1412
'**/*.+(js|ts)': ['karma-typescript'],
1513
},
16-
1714
karmaTypescriptConfig: {
1815
tsconfig: 'tsconfig.json',
1916
compilerOptions: {
@@ -30,7 +27,6 @@ module.exports = function(config) {
3027
'text-summary': '',
3128
},
3229
},
33-
3430
// Uncomment if you want to silence console logs in the output
3531
// client: {
3632
// captureConsole: false,

packages/browser/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"karma": "^2.0.2",
2929
"karma-chai": "^0.1.0",
3030
"karma-chrome-launcher": "^2.2.0",
31+
"karma-failed-reporter": "0.0.3",
32+
"karma-firefox-launcher": "^1.1.0",
3133
"karma-mocha": "^1.3.0",
3234
"karma-mocha-reporter": "^2.2.5",
3335
"karma-rollup-preprocessor": "^6.0.0",
@@ -58,8 +60,10 @@
5860
"fix": "run-s fix:tslint fix:prettier",
5961
"fix:prettier": "prettier --write '{src,test}/**/*.ts'",
6062
"fix:tslint": "tslint --fix -t stylish -p .",
61-
"test": "karma start karma.config.js",
62-
"test:watch": "karma start karma.config.js --auto-watch --no-single-run",
63+
"test": "karma start karma/karma.unit.config.js",
64+
"test:watch": "karma start karma/karma.unit.config.js --auto-watch --no-single-run",
65+
"test:integration": "karma start karma/karma.integration.config.js",
66+
"test:integration:watch": "karma start karma/karma.integration.config.js --auto-watch --no-single-run",
6367
"size:check": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print $1,\"kB\";}'",
6468
"version": "node ../../scripts/versionbump.js src/version.ts"
6569
},

0 commit comments

Comments
 (0)