Skip to content

Commit 6d373bb

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

File tree

3 files changed

+287
-454
lines changed

3 files changed

+287
-454
lines changed

packages/browser/rollup.config.js

Lines changed: 33 additions & 40 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',
@@ -31,56 +57,23 @@ export default [
3157
],
3258
},
3359
{
34-
input: 'src/index.ts',
60+
...bundleConfig,
3561
output: {
62+
...bundleConfig.output,
3663
file: 'build/bundle.js',
37-
format: 'iife',
38-
name: 'Sentry',
39-
sourcemap: true,
4064
},
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-
],
5865
},
5966
{
60-
input: 'src/index.ts',
67+
...bundleConfig,
6168
output: {
69+
...bundleConfig.output,
6270
file: 'build/bundle.min.js',
63-
format: 'iife',
64-
name: 'Sentry',
65-
sourcemap: true,
6671
},
67-
context: 'window',
6872
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(),
73+
...bundleConfig.plugins.slice(0, -1),
74+
Uglify has to be at the end of compilation, BUT before the license banner
7975
uglify(),
80-
license({
81-
sourcemap: true,
82-
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/raven-js */`,
83-
}),
76+
...bundleConfig.plugins.slice(-1),
8477
],
8578
},
8679
];

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)