Skip to content

Commit 59924de

Browse files
committed
browser: Ported all integration tests from raven-js
1 parent 65d0d41 commit 59924de

File tree

3 files changed

+294
-466
lines changed

3 files changed

+294
-466
lines changed

packages/browser/rollup.config.js

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,32 @@ const commitHash = require('child_process')
88
.execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
99
.trim();
1010

11+
const bundleConfig = {
12+
input: 'src/index.ts',
13+
output: {
14+
format: 'iife',
15+
name: 'Sentry',
16+
sourcemap: true,
17+
},
18+
context: 'window',
19+
plugins: [
20+
typescript({
21+
tsconfig: 'tsconfig.build.json',
22+
tsconfigOverride: { compilerOptions: { declaration: false } },
23+
}),
24+
resolve({
25+
jsnext: true,
26+
main: true,
27+
browser: true,
28+
}),
29+
commonjs(),
30+
license({
31+
sourcemap: true,
32+
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/raven-js */`,
33+
}),
34+
],
35+
};
36+
1137
export default [
1238
{
1339
input: 'src/index.ts',
@@ -30,57 +56,19 @@ export default [
3056
commonjs(),
3157
],
3258
},
33-
{
34-
input: 'src/index.ts',
35-
output: {
36-
file: 'build/bundle.js',
37-
format: 'iife',
38-
name: 'Sentry',
39-
sourcemap: true,
40-
},
41-
context: 'window',
42-
plugins: [
43-
typescript({
44-
tsconfig: 'tsconfig.build.json',
45-
tsconfigOverride: { compilerOptions: { declaration: false } },
46-
}),
47-
resolve({
48-
jsnext: true,
49-
main: true,
50-
browser: true,
51-
}),
52-
commonjs(),
53-
license({
54-
sourcemap: true,
55-
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/raven-js */`,
56-
}),
57-
],
58-
},
59-
{
60-
input: 'src/index.ts',
61-
output: {
59+
Object.assign({}, bundleConfig, {
60+
output: Object.assign({}, bundleConfig.output, {
6261
file: 'build/bundle.min.js',
63-
format: 'iife',
64-
name: 'Sentry',
65-
sourcemap: true,
66-
},
67-
context: 'window',
68-
plugins: [
69-
typescript({
70-
tsconfig: 'tsconfig.build.json',
71-
tsconfigOverride: { compilerOptions: { declaration: false } },
72-
}),
73-
resolve({
74-
jsnext: true,
75-
main: true,
76-
browser: true,
77-
}),
78-
commonjs(),
79-
uglify(),
80-
license({
81-
sourcemap: true,
82-
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/raven-js */`,
83-
}),
84-
],
85-
},
62+
}),
63+
}),
64+
Object.assign({}, bundleConfig, {
65+
output: Object.assign({}, bundleConfig.output, {
66+
file: 'build/bundle.js',
67+
}),
68+
// Uglify has to be at the end of compilation, BUT before the license banner
69+
plugins: bundleConfig.plugins
70+
.slice(0, -1)
71+
.concat(uglify())
72+
.concat(bundleConfig.plugins.slice(-1)),
73+
}),
8674
];

packages/browser/test/integration/frame.html

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@
8787
</script>
8888
<script src="../../build/bundle.js"></script>
8989
<script>
90-
// stub _makeRequest so we don't actually transmit any data
91-
Raven._makeRequest = function () { };
92-
9390
// store references to original, unwrapped built-ins in order to:
9491
// - get a clean, unwrapped setTimeout (so stack traces don't include
9592
// frames from mocha)
@@ -108,12 +105,34 @@
108105
consoleLog: console.log
109106
};
110107

111-
window.ravenData = [];
112-
Raven.config('https://[email protected]/1', {
113-
dataCallback: function (data) {
114-
ravenData.push(data);
108+
// expose events so we can access them in our tests
109+
window.sentryData = [];
110+
111+
// stub transport so we don't actually transmit any data
112+
function DummyTransport() { }
113+
DummyTransport.prototype.send = function (event) {
114+
// console.log(JSON.stringify(event, null, 2));
115+
sentryData.push(event);
116+
return true;
117+
}
118+
119+
Sentry.init({
120+
dsn: 'https://[email protected]/1',
121+
transport: DummyTransport,
122+
shouldAddBreadcrumb: function (breadcrumb) {
123+
// Filter internal Karma requests
124+
if (
125+
breadcrumb.type === 'http' &&
126+
(
127+
breadcrumb.data.url.indexOf('test.js') !== -1 ||
128+
breadcrumb.data.url.indexOf('frame.html') !== -1
129+
)
130+
) {
131+
return false;
132+
}
133+
return true;
115134
}
116-
}).install();
135+
})
117136

118137
function bar() {
119138
baz();

0 commit comments

Comments
 (0)