diff --git a/.eslintrc.js b/.eslintrc.js
index e1194b33b5da..659559818215 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -10,7 +10,16 @@ module.exports = {
ecmaVersion: 2018,
},
extends: ['@sentry-internal/sdk'],
- ignorePatterns: ['coverage/**', 'build/**', 'dist/**', 'esm/**', 'examples/**', 'scripts/**', 'test/manual/**'],
+ ignorePatterns: [
+ 'coverage/**',
+ 'build/**',
+ 'dist/**',
+ 'esm/**',
+ 'examples/**',
+ 'scripts/**',
+ 'test/manual/**',
+ 'types/**',
+ ],
overrides: [
{
files: ['*.ts', '*.tsx', '*.d.ts'],
diff --git a/README.md b/README.md
index c57f012bb432..84e46f6b362a 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ package. Please refer to the README and instructions of those SDKs for more deta
- [`@sentry/node`](https://github.com/getsentry/sentry-javascript/tree/master/packages/node): SDK for Node, including
integrations for Express, Koa, Loopback, Sails and Connect
- [`@sentry/angular`](https://github.com/getsentry/sentry-javascript/tree/master/packages/angular): browser SDK with Angular integration enabled
-- [`@sentry/react`](https://github.com/getsentry/sentry-javascript/tree/master/packages/react): browser SDK with React integration enabled
+- [`@sentry/react`](https://github.com/getsentry/sentry-javascript/tree/master/packages/react): browser SDK with React integration enabled
- [`@sentry/ember`](https://github.com/getsentry/sentry-javascript/tree/master/packages/ember): browser SDK with Ember integration enabled
- [`@sentry/vue`](https://github.com/getsentry/sentry-javascript/tree/master/packages/vue): browser SDK with Vue integration enabled
- [`@sentry/gatsby`](https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby): SDK for Gatsby
diff --git a/packages/browser/test/integration/.prettierrc b/packages/browser/test/integration/.prettierrc
index 757fd64caa9e..369aaabb2dae 100644
--- a/packages/browser/test/integration/.prettierrc
+++ b/packages/browser/test/integration/.prettierrc
@@ -1,3 +1,7 @@
{
+ "arrowParens": "avoid",
+ "printWidth": 120,
+ "proseWrap": "always",
+ "singleQuote": true,
"trailingComma": "es5"
}
diff --git a/packages/browser/test/integration/browsers.js b/packages/browser/test/integration/browsers.js
index ee226a872545..5230de1b991b 100644
--- a/packages/browser/test/integration/browsers.js
+++ b/packages/browser/test/integration/browsers.js
@@ -3,83 +3,83 @@
module.exports = {
bs_android_4: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Samsung Galaxy Note 4",
- os: "android",
- os_version: "4.4",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Samsung Galaxy Note 4',
+ os: 'android',
+ os_version: '4.4',
real_mobile: true,
browser_version: null,
},
bs_android_5: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Samsung Galaxy S6",
- os: "android",
- os_version: "5.0",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Samsung Galaxy S6',
+ os: 'android',
+ os_version: '5.0',
real_mobile: true,
browser_version: null,
},
bs_android_6: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Google Nexus 6",
- os: "android",
- os_version: "6.0",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Google Nexus 6',
+ os: 'android',
+ os_version: '6.0',
real_mobile: true,
browser_version: null,
},
bs_android_7: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Samsung Galaxy Note 8",
- os: "android",
- os_version: "7.1",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Samsung Galaxy Note 8',
+ os: 'android',
+ os_version: '7.1',
real_mobile: true,
browser_version: null,
},
bs_android_8: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Samsung Galaxy Note 9",
- os: "android",
- os_version: "8.1",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Samsung Galaxy Note 9',
+ os: 'android',
+ os_version: '8.1',
real_mobile: true,
browser_version: null,
},
bs_android_9: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Samsung Galaxy Note 10 Plus",
- os: "android",
- os_version: "9.0",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Samsung Galaxy Note 10 Plus',
+ os: 'android',
+ os_version: '9.0',
real_mobile: true,
browser_version: null,
},
bs_android_10: {
- base: "BrowserStack",
- browser: "Android Browser",
- device: "Google Pixel 4 XL",
- os: "android",
- os_version: "10.0",
+ base: 'BrowserStack',
+ browser: 'Android Browser',
+ device: 'Google Pixel 4 XL',
+ os: 'android',
+ os_version: '10.0',
real_mobile: true,
browser_version: null,
},
bs_ios_12: {
- base: "BrowserStack",
- browser: "Mobile Safari",
- device: "iPhone XS",
- os: "ios",
- os_version: "12",
+ base: 'BrowserStack',
+ browser: 'Mobile Safari',
+ device: 'iPhone XS',
+ os: 'ios',
+ os_version: '12',
real_mobile: true,
browser_version: null,
},
bs_ios_13: {
- base: "BrowserStack",
- browser: "Mobile Safari",
- device: "iPhone 11",
- os: "ios",
- os_version: "13",
+ base: 'BrowserStack',
+ browser: 'Mobile Safari',
+ device: 'iPhone 11',
+ os: 'ios',
+ os_version: '13',
real_mobile: true,
browser_version: null,
},
@@ -94,47 +94,47 @@ module.exports = {
// real_mobile: null,
// },
bs_ie11: {
- base: "BrowserStack",
- browser: "IE",
- browser_version: "11.0",
- os: "Windows",
- os_version: "10",
+ base: 'BrowserStack',
+ browser: 'IE',
+ browser_version: '11.0',
+ os: 'Windows',
+ os_version: '10',
device: null,
real_mobile: null,
},
bs_safari: {
- base: "BrowserStack",
- browser: "Safari",
- browser_version: "latest",
- os: "OS X",
- os_version: "Catalina",
+ base: 'BrowserStack',
+ browser: 'Safari',
+ browser_version: 'latest',
+ os: 'OS X',
+ os_version: 'Catalina',
device: null,
real_mobile: null,
},
bs_edge: {
- base: "BrowserStack",
- browser: "Edge",
- browser_version: "latest",
- os: "Windows",
- os_version: "10",
+ base: 'BrowserStack',
+ browser: 'Edge',
+ browser_version: 'latest',
+ os: 'Windows',
+ os_version: '10',
device: null,
real_mobile: null,
},
bs_firefox: {
- base: "BrowserStack",
- browser: "Firefox",
- browser_version: "latest",
- os: "Windows",
- os_version: "10",
+ base: 'BrowserStack',
+ browser: 'Firefox',
+ browser_version: 'latest',
+ os: 'Windows',
+ os_version: '10',
device: null,
real_mobile: null,
},
bs_chrome: {
- base: "BrowserStack",
- browser: "Chrome",
- browser_version: "latest",
- os: "Windows",
- os_version: "10",
+ base: 'BrowserStack',
+ browser: 'Chrome',
+ browser_version: 'latest',
+ os: 'Windows',
+ os_version: '10',
device: null,
real_mobile: null,
},
diff --git a/packages/browser/test/integration/common/init.js b/packages/browser/test/integration/common/init.js
index 564eb1269e1f..8215232aadcc 100644
--- a/packages/browser/test/integration/common/init.js
+++ b/packages/browser/test/integration/common/init.js
@@ -14,55 +14,44 @@ var breadcrumbHints = [];
// Oh dear IE10...
var dsn =
document.location.protocol +
- "//public@" +
+ '//public@' +
document.location.hostname +
- (document.location.port ? ":" + document.location.port : "") +
- "/1";
+ (document.location.port ? ':' + document.location.port : '') +
+ '/1';
function initSDK() {
Sentry.init({
dsn: dsn,
integrations: [new Sentry.Integrations.Dedupe()],
attachStacktrace: true,
- ignoreErrors: ["ignoreErrorTest"],
- denyUrls: ["foo.js"],
- beforeSend: function(event, eventHint) {
+ ignoreErrors: ['ignoreErrorTest'],
+ denyUrls: ['foo.js'],
+ beforeSend: function (event, eventHint) {
events.push(event);
eventHints.push(eventHint);
return event;
},
- beforeBreadcrumb: function(breadcrumb, breadcrumbHint) {
+ beforeBreadcrumb: function (breadcrumb, breadcrumbHint) {
// Filter console logs as we use them for debugging *a lot* and they are not *that* important
// But allow then if we explicitly say so (for one of integration tests)
- if (
- breadcrumb.category === "console" &&
- !window.allowConsoleBreadcrumbs
- ) {
+ if (breadcrumb.category === 'console' && !window.allowConsoleBreadcrumbs) {
return null;
}
// One of the tests use manually created breadcrumb without eventId and we want to let it through
- if (
- breadcrumb.category.indexOf("sentry") === 0 &&
- breadcrumb.event_id &&
- !window.allowSentryBreadcrumbs
- ) {
+ if (breadcrumb.category.indexOf('sentry') === 0 && breadcrumb.event_id && !window.allowSentryBreadcrumbs) {
return null;
}
if (
- breadcrumb.type === "http" &&
- (breadcrumb.data.url.indexOf("test.js") !== -1 ||
- breadcrumb.data.url.indexOf("frame.html") !== -1)
+ breadcrumb.type === 'http' &&
+ (breadcrumb.data.url.indexOf('test.js') !== -1 || breadcrumb.data.url.indexOf('frame.html') !== -1)
) {
return null;
}
// Filter "refresh" like navigation which occurs in Mocha when testing on Android 4
- if (
- breadcrumb.category === "navigation" &&
- breadcrumb.data.to === breadcrumb.data.from
- ) {
+ if (breadcrumb.category === 'navigation' && breadcrumb.data.to === breadcrumb.data.from) {
return null;
}
diff --git a/packages/browser/test/integration/common/triggers.js b/packages/browser/test/integration/common/triggers.js
index 4363a180cedf..e3775317a112 100644
--- a/packages/browser/test/integration/common/triggers.js
+++ b/packages/browser/test/integration/common/triggers.js
@@ -16,7 +16,7 @@ function foo2() {
function throwNonError() {
try {
- throw { foo: "bar" };
+ throw { foo: 'bar' };
} catch (o_O) {
Sentry.captureException(o_O);
}
@@ -24,7 +24,7 @@ function throwNonError() {
function throwError(message) {
// eslint-disable-next-line no-param-reassign
- message = message || "foo";
+ message = message || 'foo';
try {
throw new Error(message);
} catch (o_O) {
@@ -34,7 +34,7 @@ function throwError(message) {
function throwRandomError() {
try {
- throw new Error("Exception no " + (Date.now() + Math.random()));
+ throw new Error('Exception no ' + (Date.now() + Math.random()));
} catch (o_O) {
Sentry.captureException(o_O);
}
@@ -47,12 +47,12 @@ function throwSameConsecutiveErrors(message) {
function captureMessage(message) {
// eslint-disable-next-line no-param-reassign
- message = message || "message";
+ message = message || 'message';
Sentry.captureMessage(message);
}
function captureRandomMessage() {
- Sentry.captureMessage("Message no " + (Date.now() + Math.random()));
+ Sentry.captureMessage('Message no ' + (Date.now() + Math.random()));
}
function captureSameConsecutiveMessages(message) {
diff --git a/packages/browser/test/integration/common/utils.js b/packages/browser/test/integration/common/utils.js
index 68b4314b0f6d..e3a803151ffa 100644
--- a/packages/browser/test/integration/common/utils.js
+++ b/packages/browser/test/integration/common/utils.js
@@ -1,13 +1,13 @@
// All the functions below can be called within the iframe under the test
function supportsFetch() {
- if (!("fetch" in window)) {
+ if (!('fetch' in window)) {
return false;
}
try {
new Headers();
- new Request("");
+ new Request('');
new Response();
return true;
} catch (e) {
@@ -21,12 +21,12 @@ function supportsNativeFetch() {
}
function isNativeFunc(func) {
- return func.toString().indexOf("native") !== -1;
+ return func.toString().indexOf('native') !== -1;
}
var result = null;
if (window.document) {
- var sandbox = window.document.createElement("iframe");
+ var sandbox = window.document.createElement('iframe');
sandbox.hidden = true;
try {
window.document.head.appendChild(sandbox);
@@ -46,7 +46,7 @@ function supportsNativeFetch() {
}
function supportsOnunhandledRejection() {
- return typeof PromiseRejectionEvent !== "undefined";
+ return typeof PromiseRejectionEvent !== 'undefined';
}
function isBelowIE11() {
@@ -58,7 +58,7 @@ function isBelowIE11() {
// (╯°□°)╯︵ ┻━┻
function canReadFunctionName() {
function foo() {}
- if (foo.name === "foo") return true;
+ if (foo.name === 'foo') return true;
return false;
}
@@ -67,7 +67,7 @@ function waitForXHR(xhr, cb) {
return cb();
}
- setTimeout(function() {
+ setTimeout(function () {
waitForXHR(xhr, cb);
}, 1000 / 60);
}
diff --git a/packages/browser/test/integration/karma.conf.js b/packages/browser/test/integration/karma.conf.js
index 060229d71508..c8d8ae783979 100644
--- a/packages/browser/test/integration/karma.conf.js
+++ b/packages/browser/test/integration/karma.conf.js
@@ -1,19 +1,16 @@
-const path = require("path");
+const path = require('path');
-const playwright = require("playwright");
+const playwright = require('playwright');
process.env.CHROME_BIN = playwright.chromium.executablePath();
process.env.FIREFOX_BIN = playwright.firefox.executablePath();
process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath();
const browserstackUsername = process.env.BROWSERSTACK_USERNAME;
const browserstackAccessKey = process.env.BROWSERSTACK_ACCESS_KEY;
-const isLocalRun =
- browserstackUsername === undefined || browserstackAccessKey === undefined;
+const isLocalRun = browserstackUsername === undefined || browserstackAccessKey === undefined;
-const customLaunchers = isLocalRun ? {} : require("./browsers.js");
-const browsers = isLocalRun
- ? [process.env.KARMA_BROWSER || "ChromeHeadless"]
- : Object.keys(customLaunchers);
+const customLaunchers = isLocalRun ? {} : require('./browsers.js');
+const browsers = isLocalRun ? [process.env.KARMA_BROWSER || 'ChromeHeadless'] : Object.keys(customLaunchers);
// NOTE: It "should" work as a global `build` config option, but it doesn't, so setting it up
// for each browser here, so that we have a nice distinction of when the tests were run exactly.
@@ -25,35 +22,30 @@ if (!isLocalRun) {
}
}
-const plugins = [
- "karma-mocha",
- "karma-chai",
- "karma-sinon",
- "karma-mocha-reporter",
-];
-const reporters = ["mocha"];
+const plugins = ['karma-mocha', 'karma-chai', 'karma-sinon', 'karma-mocha-reporter'];
+const reporters = ['mocha'];
if (isLocalRun) {
- plugins.push("karma-chrome-launcher");
- plugins.push("karma-firefox-launcher");
- plugins.push("karma-webkit-launcher");
+ plugins.push('karma-chrome-launcher');
+ plugins.push('karma-firefox-launcher');
+ plugins.push('karma-webkit-launcher');
} else {
- plugins.push("karma-browserstack-launcher");
- reporters.push("BrowserStack");
+ plugins.push('karma-browserstack-launcher');
+ reporters.push('BrowserStack');
}
const files = [
// Files common across all test-cases (polyfills, setup, loader, sdk), but not tests themselves
{
- pattern: path.resolve(__dirname, "artifacts/!(tests).js"),
+ pattern: path.resolve(__dirname, 'artifacts/!(tests).js'),
included: false,
},
// Files used to trigger errors/provide data
- { pattern: path.resolve(__dirname, "subjects/*"), included: false },
+ { pattern: path.resolve(__dirname, 'subjects/*'), included: false },
// HTML shells for all test suites
- { pattern: path.resolve(__dirname, "variants/*"), included: false },
+ { pattern: path.resolve(__dirname, 'variants/*'), included: false },
// Tests themselves - only this file is included in the index.html generated by Mocha
- { pattern: path.resolve(__dirname, "artifacts/tests.js"), included: true },
+ { pattern: path.resolve(__dirname, 'artifacts/tests.js'), included: true },
];
module.exports = config => {
@@ -76,15 +68,15 @@ module.exports = config => {
singleRun: true,
autoWatch: false,
basePath: __dirname,
- hostname: isLocalRun ? "localhost" : "bs-local.com",
+ hostname: isLocalRun ? 'localhost' : 'bs-local.com',
proxies: {
// Required for non-string fetch url test
- "/base/variants/123": "/base/subjects/123",
+ '/base/variants/123': '/base/subjects/123',
// Supresses warnings
- "/api/1/store/": "/",
- "/api/1/envelope/": "/",
+ '/api/1/store/': '/',
+ '/api/1/envelope/': '/',
},
- frameworks: ["mocha", "chai", "sinon"],
+ frameworks: ['mocha', 'chai', 'sinon'],
files,
plugins,
reporters,
@@ -92,8 +84,8 @@ module.exports = config => {
browsers,
client: {
mocha: {
- reporter: "html",
- ui: "bdd",
+ reporter: 'html',
+ ui: 'bdd',
},
},
concurrency: isLocalRun ? 1 : 2,
diff --git a/packages/browser/test/integration/polyfills/events.js b/packages/browser/test/integration/polyfills/events.js
index 6c9b3a2a8fcf..d7d28816f4f7 100644
--- a/packages/browser/test/integration/polyfills/events.js
+++ b/packages/browser/test/integration/polyfills/events.js
@@ -7,33 +7,17 @@
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
*/
-(function() {
+(function () {
try {
- new MouseEvent("click");
+ new MouseEvent('click');
return false; // No need to polyfill
} catch (e) {
// Need to polyfill - fall through
}
- var MouseEvent = function(eventType) {
- var mouseEvent = document.createEvent("MouseEvent");
- mouseEvent.initMouseEvent(
- eventType,
- true,
- true,
- window,
- 0,
- 0,
- 0,
- 0,
- 0,
- false,
- false,
- false,
- false,
- 0,
- null
- );
+ var MouseEvent = function (eventType) {
+ var mouseEvent = document.createEvent('MouseEvent');
+ mouseEvent.initMouseEvent(eventType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
return mouseEvent;
};
@@ -41,41 +25,20 @@
window.MouseEvent = MouseEvent;
})();
-(function() {
+(function () {
try {
- new KeyboardEvent("keypress");
+ new KeyboardEvent('keypress');
return false; // No need to polyfill
} catch (e) {
// Need to polyfill - fall through
}
- var KeyboardEvent = function(eventType) {
- var keyboardEvent = document.createEvent("KeyboardEvent");
+ var KeyboardEvent = function (eventType) {
+ var keyboardEvent = document.createEvent('KeyboardEvent');
if (keyboardEvent.initKeyboardEvent)
- keyboardEvent.initKeyboardEvent(
- eventType,
- true,
- true,
- window,
- false,
- false,
- false,
- false,
- "a",
- 0
- );
+ keyboardEvent.initKeyboardEvent(eventType, true, true, window, false, false, false, false, 'a', 0);
if (keyboardEvent.initKeyEvent)
- keyboardEvent.initKeyEvent(
- eventType,
- true,
- true,
- window,
- false,
- false,
- false,
- false,
- "a"
- );
+ keyboardEvent.initKeyEvent(eventType, true, true, window, false, false, false, false, 'a');
return keyboardEvent;
};
@@ -83,19 +46,14 @@
window.KeyboardEvent = KeyboardEvent;
})();
-(function() {
- if (typeof window.CustomEvent === "function") return false;
+(function () {
+ if (typeof window.CustomEvent === 'function') return false;
function CustomEvent(event, params) {
// eslint-disable-next-line no-param-reassign
params = params || { bubbles: false, cancelable: false, detail: null };
- var evt = document.createEvent("CustomEvent");
- evt.initCustomEvent(
- event,
- params.bubbles,
- params.cancelable,
- params.detail
- );
+ var evt = document.createEvent('CustomEvent');
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
diff --git a/packages/browser/test/integration/polyfills/fetch.js b/packages/browser/test/integration/polyfills/fetch.js
index 277a3dee19ce..97186e4236bb 100644
--- a/packages/browser/test/integration/polyfills/fetch.js
+++ b/packages/browser/test/integration/polyfills/fetch.js
@@ -6,22 +6,22 @@
* @version v3.0.0+cc84bc28
*/
-(function(global, factory) {
- typeof exports === "object" && typeof module !== "undefined"
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
? factory(exports)
- : typeof define === "function" && define.amd
- ? define(["exports"], factory)
+ : typeof define === 'function' && define.amd
+ ? define(['exports'], factory)
: factory((global.WHATWGFetch = {}));
-})(this, function(exports) {
- "use strict";
+})(this, function (exports) {
+ 'use strict';
var support = {
- searchParams: "URLSearchParams" in self,
- iterable: "Symbol" in self && "iterator" in Symbol,
+ searchParams: 'URLSearchParams' in self,
+ iterable: 'Symbol' in self && 'iterator' in Symbol,
blob:
- "FileReader" in self &&
- "Blob" in self &&
- (function() {
+ 'FileReader' in self &&
+ 'Blob' in self &&
+ (function () {
try {
new Blob();
return true;
@@ -29,8 +29,8 @@
return false;
}
})(),
- formData: "FormData" in self,
- arrayBuffer: "ArrayBuffer" in self,
+ formData: 'FormData' in self,
+ arrayBuffer: 'ArrayBuffer' in self,
};
function isDataView(obj) {
@@ -39,39 +39,37 @@
if (support.arrayBuffer) {
var viewClasses = [
- "[object Int8Array]",
- "[object Uint8Array]",
- "[object Uint8ClampedArray]",
- "[object Int16Array]",
- "[object Uint16Array]",
- "[object Int32Array]",
- "[object Uint32Array]",
- "[object Float32Array]",
- "[object Float64Array]",
+ '[object Int8Array]',
+ '[object Uint8Array]',
+ '[object Uint8ClampedArray]',
+ '[object Int16Array]',
+ '[object Uint16Array]',
+ '[object Int32Array]',
+ '[object Uint32Array]',
+ '[object Float32Array]',
+ '[object Float64Array]',
];
var isArrayBufferView =
ArrayBuffer.isView ||
- function(obj) {
- return (
- obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
- );
+ function (obj) {
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
};
}
function normalizeName(name) {
- if (typeof name !== "string") {
+ if (typeof name !== 'string') {
// eslint-disable-next-line no-param-reassign
name = String(name);
}
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
- throw new TypeError("Invalid character in header field name");
+ throw new TypeError('Invalid character in header field name');
}
return name.toLowerCase();
}
function normalizeValue(value) {
- if (typeof value !== "string") {
+ if (typeof value !== 'string') {
// eslint-disable-next-line no-param-reassign
value = String(value);
}
@@ -81,14 +79,14 @@
// Build a destructive iterator for the value list
function iteratorFor(items) {
var iterator = {
- next: function() {
+ next: function () {
var value = items.shift();
return { done: value === undefined, value: value };
},
};
if (support.iterable) {
- iterator[Symbol.iterator] = function() {
+ iterator[Symbol.iterator] = function () {
return iterator;
};
}
@@ -100,48 +98,48 @@
this.map = {};
if (headers instanceof Headers) {
- headers.forEach(function(value, name) {
+ headers.forEach(function (value, name) {
this.append(name, value);
}, this);
} else if (Array.isArray(headers)) {
- headers.forEach(function(header) {
+ headers.forEach(function (header) {
this.append(header[0], header[1]);
}, this);
} else if (headers) {
- Object.getOwnPropertyNames(headers).forEach(function(name) {
+ Object.getOwnPropertyNames(headers).forEach(function (name) {
this.append(name, headers[name]);
}, this);
}
}
- Headers.prototype.append = function(name, value) {
+ Headers.prototype.append = function (name, value) {
// eslint-disable-next-line no-param-reassign
name = normalizeName(name);
// eslint-disable-next-line no-param-reassign
value = normalizeValue(value);
var oldValue = this.map[name];
- this.map[name] = oldValue ? oldValue + ", " + value : value;
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
};
- Headers.prototype["delete"] = function(name) {
+ Headers.prototype['delete'] = function (name) {
delete this.map[normalizeName(name)];
};
- Headers.prototype.get = function(name) {
+ Headers.prototype.get = function (name) {
// eslint-disable-next-line no-param-reassign
name = normalizeName(name);
return this.has(name) ? this.map[name] : null;
};
- Headers.prototype.has = function(name) {
+ Headers.prototype.has = function (name) {
return this.map.hasOwnProperty(normalizeName(name));
};
- Headers.prototype.set = function(name, value) {
+ Headers.prototype.set = function (name, value) {
this.map[normalizeName(name)] = normalizeValue(value);
};
- Headers.prototype.forEach = function(callback, thisArg) {
+ Headers.prototype.forEach = function (callback, thisArg) {
for (var name in this.map) {
if (this.map.hasOwnProperty(name)) {
callback.call(thisArg, this.map[name], name, this);
@@ -149,25 +147,25 @@
}
};
- Headers.prototype.keys = function() {
+ Headers.prototype.keys = function () {
var items = [];
- this.forEach(function(value, name) {
+ this.forEach(function (value, name) {
items.push(name);
});
return iteratorFor(items);
};
- Headers.prototype.values = function() {
+ Headers.prototype.values = function () {
var items = [];
- this.forEach(function(value) {
+ this.forEach(function (value) {
items.push(value);
});
return iteratorFor(items);
};
- Headers.prototype.entries = function() {
+ Headers.prototype.entries = function () {
var items = [];
- this.forEach(function(value, name) {
+ this.forEach(function (value, name) {
items.push([name, value]);
});
return iteratorFor(items);
@@ -179,17 +177,17 @@
function consumed(body) {
if (body.bodyUsed) {
- return Promise.reject(new TypeError("Already read"));
+ return Promise.reject(new TypeError('Already read'));
}
body.bodyUsed = true;
}
function fileReaderReady(reader) {
- return new Promise(function(resolve, reject) {
- reader.onload = function() {
+ return new Promise(function (resolve, reject) {
+ reader.onload = function () {
resolve(reader.result);
};
- reader.onerror = function() {
+ reader.onerror = function () {
reject(reader.error);
};
});
@@ -216,7 +214,7 @@
for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i]);
}
- return chars.join("");
+ return chars.join('');
}
function bufferClone(buf) {
@@ -233,54 +231,42 @@
this.bodyUsed = false;
// eslint-disable-next-line complexity
- this._initBody = function(body) {
+ this._initBody = function (body) {
this._bodyInit = body;
if (!body) {
- this._bodyText = "";
- } else if (typeof body === "string") {
+ this._bodyText = '';
+ } else if (typeof body === 'string') {
this._bodyText = body;
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body;
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body;
- } else if (
- support.searchParams &&
- URLSearchParams.prototype.isPrototypeOf(body)
- ) {
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString();
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer);
// IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer]);
- } else if (
- support.arrayBuffer &&
- (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))
- ) {
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
this._bodyArrayBuffer = bufferClone(body);
} else {
// eslint-disable-next-line no-param-reassign
this._bodyText = body = Object.prototype.toString.call(body);
}
- if (!this.headers.get("content-type")) {
- if (typeof body === "string") {
- this.headers.set("content-type", "text/plain;charset=UTF-8");
+ if (!this.headers.get('content-type')) {
+ if (typeof body === 'string') {
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
} else if (this._bodyBlob && this._bodyBlob.type) {
- this.headers.set("content-type", this._bodyBlob.type);
- } else if (
- support.searchParams &&
- URLSearchParams.prototype.isPrototypeOf(body)
- ) {
- this.headers.set(
- "content-type",
- "application/x-www-form-urlencoded;charset=UTF-8"
- );
+ this.headers.set('content-type', this._bodyBlob.type);
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
}
}
};
if (support.blob) {
- this.blob = function() {
+ this.blob = function () {
var rejected = consumed(this);
if (rejected) {
return rejected;
@@ -291,13 +277,13 @@
} else if (this._bodyArrayBuffer) {
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
} else if (this._bodyFormData) {
- throw new Error("could not read FormData body as blob");
+ throw new Error('could not read FormData body as blob');
} else {
return Promise.resolve(new Blob([this._bodyText]));
}
};
- this.arrayBuffer = function() {
+ this.arrayBuffer = function () {
if (this._bodyArrayBuffer) {
return consumed(this) || Promise.resolve(this._bodyArrayBuffer);
} else {
@@ -306,7 +292,7 @@
};
}
- this.text = function() {
+ this.text = function () {
var rejected = consumed(this);
if (rejected) {
return rejected;
@@ -317,19 +303,19 @@
} else if (this._bodyArrayBuffer) {
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
} else if (this._bodyFormData) {
- throw new Error("could not read FormData body as text");
+ throw new Error('could not read FormData body as text');
} else {
return Promise.resolve(this._bodyText);
}
};
if (support.formData) {
- this.formData = function() {
+ this.formData = function () {
return this.text().then(decode);
};
}
- this.json = function() {
+ this.json = function () {
return this.text().then(JSON.parse);
};
@@ -337,7 +323,7 @@
}
// HTTP methods whose capitalization should be normalized
- var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
function normalizeMethod(method) {
var upcased = method.toUpperCase();
@@ -351,7 +337,7 @@
if (input instanceof Request) {
if (input.bodyUsed) {
- throw new TypeError("Already read");
+ throw new TypeError('Already read');
}
this.url = input.url;
this.credentials = input.credentials;
@@ -369,22 +355,22 @@
this.url = String(input);
}
- this.credentials = options.credentials || this.credentials || "same-origin";
+ this.credentials = options.credentials || this.credentials || 'same-origin';
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
}
- this.method = normalizeMethod(options.method || this.method || "GET");
+ this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null;
this.signal = options.signal || this.signal;
this.referrer = null;
- if ((this.method === "GET" || this.method === "HEAD") && body) {
- throw new TypeError("Body not allowed for GET or HEAD requests");
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
+ throw new TypeError('Body not allowed for GET or HEAD requests');
}
this._initBody(body);
}
- Request.prototype.clone = function() {
+ Request.prototype.clone = function () {
return new Request(this, { body: this._bodyInit });
};
@@ -392,12 +378,12 @@
var form = new FormData();
body
.trim()
- .split("&")
- .forEach(function(bytes) {
+ .split('&')
+ .forEach(function (bytes) {
if (bytes) {
- var split = bytes.split("=");
- var name = split.shift().replace(/\+/g, " ");
- var value = split.join("=").replace(/\+/g, " ");
+ var split = bytes.split('=');
+ var name = split.shift().replace(/\+/g, ' ');
+ var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value));
}
});
@@ -408,12 +394,12 @@
var headers = new Headers();
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
// https://tools.ietf.org/html/rfc7230#section-3.2
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
- preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
- var parts = line.split(":");
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
+ preProcessedHeaders.split(/\r?\n/).forEach(function (line) {
+ var parts = line.split(':');
var key = parts.shift().trim();
if (key) {
- var value = parts.join(":").trim();
+ var value = parts.join(':').trim();
headers.append(key, value);
}
});
@@ -428,18 +414,18 @@
options = {};
}
- this.type = "default";
+ this.type = 'default';
this.status = options.status === undefined ? 200 : options.status;
this.ok = this.status >= 200 && this.status < 300;
- this.statusText = "statusText" in options ? options.statusText : "OK";
+ this.statusText = 'statusText' in options ? options.statusText : 'OK';
this.headers = new Headers(options.headers);
- this.url = options.url || "";
+ this.url = options.url || '';
this._initBody(bodyInit);
}
Body.call(Response.prototype);
- Response.prototype.clone = function() {
+ Response.prototype.clone = function () {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
@@ -448,17 +434,17 @@
});
};
- Response.error = function() {
- var response = new Response(null, { status: 0, statusText: "" });
- response.type = "error";
+ Response.error = function () {
+ var response = new Response(null, { status: 0, statusText: '' });
+ response.type = 'error';
return response;
};
var redirectStatuses = [301, 302, 303, 307, 308];
- Response.redirect = function(url, status) {
+ Response.redirect = function (url, status) {
if (redirectStatuses.indexOf(status) === -1) {
- throw new RangeError("Invalid status code");
+ throw new RangeError('Invalid status code');
}
return new Response(null, { status: status, headers: { location: url } });
@@ -468,7 +454,7 @@
try {
new exports.DOMException();
} catch (err) {
- exports.DOMException = function(message, name) {
+ exports.DOMException = function (message, name) {
this.message = message;
this.name = name;
var error = Error(message);
@@ -479,11 +465,11 @@
}
function fetch(input, init) {
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
var request = new Request(input, init);
if (request.signal && request.signal.aborted) {
- return reject(new exports.DOMException("Aborted", "AbortError"));
+ return reject(new exports.DOMException('Aborted', 'AbortError'));
}
var xhr = new XMLHttpRequest();
@@ -492,62 +478,57 @@
xhr.abort();
}
- xhr.onload = function() {
+ xhr.onload = function () {
var options = {
status: xhr.status,
statusText: xhr.statusText,
- headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
+ headers: parseHeaders(xhr.getAllResponseHeaders() || ''),
};
- options.url =
- "responseURL" in xhr
- ? xhr.responseURL
- : options.headers.get("X-Request-URL");
- var body = "response" in xhr ? xhr.response : xhr.responseText;
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
resolve(new Response(body, options));
};
- xhr.onerror = function() {
- reject(new TypeError("Network request failed"));
+ xhr.onerror = function () {
+ reject(new TypeError('Network request failed'));
};
- xhr.ontimeout = function() {
- reject(new TypeError("Network request failed"));
+ xhr.ontimeout = function () {
+ reject(new TypeError('Network request failed'));
};
- xhr.onabort = function() {
- reject(new exports.DOMException("Aborted", "AbortError"));
+ xhr.onabort = function () {
+ reject(new exports.DOMException('Aborted', 'AbortError'));
};
xhr.open(request.method, request.url, true);
- if (request.credentials === "include") {
+ if (request.credentials === 'include') {
xhr.withCredentials = true;
- } else if (request.credentials === "omit") {
+ } else if (request.credentials === 'omit') {
xhr.withCredentials = false;
}
- if ("responseType" in xhr && support.blob) {
- xhr.responseType = "blob";
+ if ('responseType' in xhr && support.blob) {
+ xhr.responseType = 'blob';
}
- request.headers.forEach(function(value, name) {
+ request.headers.forEach(function (value, name) {
xhr.setRequestHeader(name, value);
});
if (request.signal) {
- request.signal.addEventListener("abort", abortXhr);
+ request.signal.addEventListener('abort', abortXhr);
- xhr.onreadystatechange = function() {
+ xhr.onreadystatechange = function () {
// DONE (success or failure)
if (xhr.readyState === 4) {
- request.signal.removeEventListener("abort", abortXhr);
+ request.signal.removeEventListener('abort', abortXhr);
}
};
}
- xhr.send(
- typeof request._bodyInit === "undefined" ? null : request._bodyInit
- );
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
});
}
@@ -565,5 +546,5 @@
exports.Response = Response;
exports.fetch = fetch;
- Object.defineProperty(exports, "__esModule", { value: true });
+ Object.defineProperty(exports, '__esModule', { value: true });
});
diff --git a/packages/browser/test/integration/polyfills/promise.js b/packages/browser/test/integration/polyfills/promise.js
index 5082e75d5820..5215bf5eb59b 100644
--- a/packages/browser/test/integration/polyfills/promise.js
+++ b/packages/browser/test/integration/polyfills/promise.js
@@ -6,30 +6,30 @@
* @version v4.2.8+1e68dce6
*/
-(function(global, factory) {
- typeof exports === "object" && typeof module !== "undefined"
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
? (module.exports = factory())
- : typeof define === "function" && define.amd
+ : typeof define === 'function' && define.amd
? define(factory)
: (global.ES6Promise = factory());
-})(this, function() {
- "use strict";
+})(this, function () {
+ 'use strict';
function objectOrFunction(x) {
var type = typeof x;
- return x !== null && (type === "object" || type === "function");
+ return x !== null && (type === 'object' || type === 'function');
}
function isFunction(x) {
- return typeof x === "function";
+ return typeof x === 'function';
}
var _isArray = void 0;
if (Array.isArray) {
_isArray = Array.isArray;
} else {
- _isArray = function(x) {
- return Object.prototype.toString.call(x) === "[object Array]";
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
};
}
@@ -63,34 +63,31 @@
asap = asapFn;
}
- var browserWindow = typeof window !== "undefined" ? window : undefined;
+ var browserWindow = typeof window !== 'undefined' ? window : undefined;
var browserGlobal = browserWindow || {};
- var BrowserMutationObserver =
- browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+ var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
var isNode =
- typeof self === "undefined" &&
- typeof process !== "undefined" &&
- {}.toString.call(process) === "[object process]";
+ typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
// test for web worker but not in IE10
var isWorker =
- typeof Uint8ClampedArray !== "undefined" &&
- typeof importScripts !== "undefined" &&
- typeof MessageChannel !== "undefined";
+ typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
// node
function useNextTick() {
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
// see https://github.com/cujojs/when/issues/410 for details
- return function() {
+ return function () {
return process.nextTick(flush);
};
}
// vertx
function useVertxTimer() {
- if (typeof vertxNext !== "undefined") {
- return function() {
+ if (typeof vertxNext !== 'undefined') {
+ return function () {
vertxNext(flush);
};
}
@@ -101,10 +98,10 @@
function useMutationObserver() {
var iterations = 0;
var observer = new BrowserMutationObserver(flush);
- var node = document.createTextNode("");
+ var node = document.createTextNode('');
observer.observe(node, { characterData: true });
- return function() {
+ return function () {
// eslint-disable-next-line no-plusplus
node.data = iterations = ++iterations % 2;
};
@@ -114,7 +111,7 @@
function useMessageChannel() {
var channel = new MessageChannel();
channel.port1.onmessage = flush;
- return function() {
+ return function () {
return channel.port2.postMessage(0);
};
}
@@ -123,7 +120,7 @@
// Store setTimeout reference so es6-promise will be unaffected by
// other code modifying setTimeout (like sinon.useFakeTimers())
var globalSetTimeout = setTimeout;
- return function() {
+ return function () {
return globalSetTimeout(flush, 1);
};
}
@@ -145,7 +142,7 @@
function attemptVertx() {
try {
- var vertx = Function("return this")().require("vertx");
+ var vertx = Function('return this')().require('vertx');
vertxNext = vertx.runOnLoop || vertx.runOnContext;
return useVertxTimer();
} catch (e) {
@@ -161,7 +158,7 @@
scheduleFlush = useMutationObserver();
} else if (isWorker) {
scheduleFlush = useMessageChannel();
- } else if (browserWindow === undefined && typeof require === "function") {
+ } else if (browserWindow === undefined && typeof require === 'function') {
scheduleFlush = attemptVertx();
} else {
scheduleFlush = useSetTimeout();
@@ -180,7 +177,7 @@
if (_state) {
var callback = arguments[_state - 1];
- asap(function() {
+ asap(function () {
return invokeCallback(_state, child, callback, parent._result);
});
} else {
@@ -225,11 +222,7 @@
/* jshint validthis:true */
var Constructor = this;
- if (
- object &&
- typeof object === "object" &&
- object.constructor === Constructor
- ) {
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
return object;
}
@@ -238,9 +231,7 @@
return promise;
}
- var PROMISE_ID = Math.random()
- .toString(36)
- .substring(2);
+ var PROMISE_ID = Math.random().toString(36).substring(2);
function noop() {}
@@ -249,13 +240,11 @@
var REJECTED = 2;
function selfFulfillment() {
- return new TypeError("You cannot resolve a promise with itself");
+ return new TypeError('You cannot resolve a promise with itself');
}
function cannotReturnOwn() {
- return new TypeError(
- "A promises callback cannot return that same promise."
- );
+ return new TypeError('A promises callback cannot return that same promise.');
}
function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
@@ -267,12 +256,12 @@
}
function handleForeignThenable(promise, thenable, then$$1) {
- asap(function(promise) {
+ asap(function (promise) {
var sealed = false;
var error = tryThen(
then$$1,
thenable,
- function(value) {
+ function (value) {
if (sealed) {
return;
}
@@ -283,7 +272,7 @@
fulfill(promise, value);
}
},
- function(reason) {
+ function (reason) {
if (sealed) {
return;
}
@@ -291,7 +280,7 @@
reject(promise, reason);
},
- "Settle: " + (promise._label || " unknown promise")
+ 'Settle: ' + (promise._label || ' unknown promise')
);
if (!sealed && error) {
@@ -310,10 +299,10 @@
subscribe(
thenable,
undefined,
- function(value) {
+ function (value) {
return resolve(promise, value);
},
- function(reason) {
+ function (reason) {
return reject(promise, reason);
}
);
@@ -490,10 +479,10 @@
}
function validationError() {
- return new Error("Array Methods must be provided an Array");
+ return new Error('Array Methods must be provided an Array');
}
- var Enumerator = (function() {
+ var Enumerator = (function () {
function Enumerator(Constructor, input) {
this._instanceConstructor = Constructor;
this.promise = new Constructor(noop);
@@ -545,7 +534,7 @@
if (_then === then && entry._state !== PENDING) {
this._settledAt(entry._state, i, entry._result);
- } else if (typeof _then !== "function") {
+ } else if (typeof _then !== 'function') {
this._remaining -= 1;
this._result[i] = entry;
} else if (c === Promise$2) {
@@ -558,7 +547,7 @@
this._willSettleAt(promise, i);
} else {
this._willSettleAt(
- new c(function(resolve$$1) {
+ new c(function (resolve$$1) {
return resolve$$1(entry);
}),
i
@@ -593,10 +582,10 @@
subscribe(
promise,
undefined,
- function(value) {
+ function (value) {
return enumerator._settledAt(FULFILLED, i, value);
},
- function(reason) {
+ function (reason) {
return enumerator._settledAt(REJECTED, i, reason);
}
);
@@ -726,11 +715,11 @@
var Constructor = this;
if (!isArray(entries)) {
- return new Constructor(function(_, reject) {
- return reject(new TypeError("You must pass an array to race."));
+ return new Constructor(function (_, reject) {
+ return reject(new TypeError('You must pass an array to race.'));
});
} else {
- return new Constructor(function(resolve, reject) {
+ return new Constructor(function (resolve, reject) {
var length = entries.length;
for (var i = 0; i < length; i++) {
Constructor.resolve(entries[i]).then(resolve, reject);
@@ -782,9 +771,7 @@
}
function needsResolver() {
- throw new TypeError(
- "You must pass a resolver function as the first argument to the promise constructor"
- );
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
function needsNew() {
@@ -897,17 +884,15 @@
@constructor
*/
- var Promise$2 = (function() {
+ var Promise$2 = (function () {
function Promise(resolver) {
this[PROMISE_ID] = nextId();
this._result = this._state = undefined;
this._subscribers = [];
if (noop !== resolver) {
- typeof resolver !== "function" && needsResolver();
- this instanceof Promise
- ? initializePromise(this, resolver)
- : needsNew();
+ typeof resolver !== 'function' && needsResolver();
+ this instanceof Promise ? initializePromise(this, resolver) : needsNew();
}
}
@@ -1145,13 +1130,13 @@
if (isFunction(callback)) {
return promise.then(
- function(value) {
- return constructor.resolve(callback()).then(function() {
+ function (value) {
+ return constructor.resolve(callback()).then(function () {
return value;
});
},
- function(reason) {
- return constructor.resolve(callback()).then(function() {
+ function (reason) {
+ return constructor.resolve(callback()).then(function () {
throw reason;
});
}
@@ -1176,17 +1161,15 @@
function polyfill() {
var local = void 0;
- if (typeof global !== "undefined") {
+ if (typeof global !== 'undefined') {
local = global;
- } else if (typeof self !== "undefined") {
+ } else if (typeof self !== 'undefined') {
local = self;
} else {
try {
- local = Function("return this")();
+ local = Function('return this')();
} catch (e) {
- throw new Error(
- "polyfill failed because global object is unavailable in this environment"
- );
+ throw new Error('polyfill failed because global object is unavailable in this environment');
}
}
@@ -1200,7 +1183,7 @@
// silently ignored
}
- if (promiseToString === "[object Promise]" && !P.cast) {
+ if (promiseToString === '[object Promise]' && !P.cast) {
return;
}
}
diff --git a/packages/browser/test/integration/polyfills/raf.js b/packages/browser/test/integration/polyfills/raf.js
index 61d805ee1300..1d6bc9935c65 100644
--- a/packages/browser/test/integration/polyfills/raf.js
+++ b/packages/browser/test/integration/polyfills/raf.js
@@ -6,21 +6,20 @@
*
* MIT license
*/
-(function() {
+(function () {
var lastTime = 0;
- var vendors = ["ms", "moz", "webkit", "o"];
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
- window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
+ window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame =
- window[vendors[x] + "CancelAnimationFrame"] ||
- window[vendors[x] + "CancelRequestAnimationFrame"];
+ window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
- window.requestAnimationFrame = function(callback, _element) {
+ window.requestAnimationFrame = function (callback, _element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
- var id = window.setTimeout(function() {
+ var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
@@ -28,7 +27,7 @@
};
if (!window.cancelAnimationFrame)
- window.cancelAnimationFrame = function(id) {
+ window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
})();
diff --git a/packages/browser/test/integration/run.js b/packages/browser/test/integration/run.js
index 34ce6a090537..28fcf331f6ef 100755
--- a/packages/browser/test/integration/run.js
+++ b/packages/browser/test/integration/run.js
@@ -1,15 +1,15 @@
#!/usr/bin/env node
-const fs = require("fs");
-const path = require("path");
+const fs = require('fs');
+const path = require('path');
-const rimraf = require("rimraf");
-const karma = require("karma");
-const chokidar = require("chokidar");
+const rimraf = require('rimraf');
+const karma = require('karma');
+const chokidar = require('chokidar');
-const isDebugMode = process.argv.some(x => x === "--debug");
-const isWatchMode = process.argv.some(x => x === "--watch");
-const isManualMode = process.argv.some(x => x === "--manual");
+const isDebugMode = process.argv.some(x => x === '--debug');
+const isWatchMode = process.argv.some(x => x === '--watch');
+const isManualMode = process.argv.some(x => x === '--manual');
function log(...message) {
if (isDebugMode) {
@@ -18,7 +18,7 @@ function log(...message) {
}
function readFile(file) {
- return fs.readFileSync(path.resolve(__dirname, file), "utf8");
+ return fs.readFileSync(path.resolve(__dirname, file), 'utf8');
}
function writeFile(file, data) {
@@ -27,31 +27,23 @@ function writeFile(file, data) {
// eslint-disable-next-line no-unused-vars
function copyFile(from, to) {
- log("Copying file:\n\t=> from:", from, "\n\t=> to:", to);
+ log('Copying file:\n\t=> from:', from, '\n\t=> to:', to);
fs.copyFileSync(path.resolve(__dirname, from), path.resolve(__dirname, to));
}
function concatFiles(outputFile, inputFiles) {
- log(
- "Concatinating:\n\t=> from:",
- inputFiles.join(", "),
- "\n\t=> to:",
- outputFile
- );
- writeFile(outputFile, inputFiles.map(file => readFile(file)).join("\n"));
+ log('Concatinating:\n\t=> from:', inputFiles.join(', '), '\n\t=> to:', outputFile);
+ writeFile(outputFile, inputFiles.map(file => readFile(file)).join('\n'));
}
function replacePlaceholders(templateFile) {
- log("Replacing placeholders for file:", templateFile);
-
- return readFile(templateFile).replace(
- /\{\{ ?([a-zA-Z-_./]+) ?\}\}/g,
- match => {
- const matchFile = match.slice(2, -2).trim();
- log("\t=> matched placeholder:", matchFile);
- return readFile(matchFile);
- }
- );
+ log('Replacing placeholders for file:', templateFile);
+
+ return readFile(templateFile).replace(/\{\{ ?([a-zA-Z-_./]+) ?\}\}/g, match => {
+ const matchFile = match.slice(2, -2).trim();
+ log('\t=> matched placeholder:', matchFile);
+ return readFile(matchFile);
+ });
}
function mkdir(dirpath) {
@@ -69,53 +61,32 @@ function build() {
╚════════════════════════════╝
`);
- rmdir("artifacts");
- mkdir("artifacts");
+ rmdir('artifacts');
+ mkdir('artifacts');
- concatFiles("artifacts/polyfills.js", [
- "polyfills/promise.js",
- "polyfills/fetch.js",
- "polyfills/raf.js",
- "polyfills/events.js",
+ concatFiles('artifacts/polyfills.js', [
+ 'polyfills/promise.js',
+ 'polyfills/fetch.js',
+ 'polyfills/raf.js',
+ 'polyfills/events.js',
]);
writeFile(
- "artifacts/dedupe.js",
- readFile("../../../integrations/build/dedupe.js").replace(
- "//# sourceMappingURL=dedupe.js.map",
- ""
- )
+ 'artifacts/dedupe.js',
+ readFile('../../../integrations/build/dedupe.js').replace('//# sourceMappingURL=dedupe.js.map', '')
);
- concatFiles("artifacts/setup.js", [
- "artifacts/dedupe.js",
- "common/utils.js",
- "common/triggers.js",
- "common/init.js",
- ]);
- rmdir("artifacts/dedupe.js");
+ concatFiles('artifacts/setup.js', ['artifacts/dedupe.js', 'common/utils.js', 'common/triggers.js', 'common/init.js']);
+ rmdir('artifacts/dedupe.js');
+ writeFile('artifacts/sdk.js', readFile('../../build/bundle.js').replace('//# sourceMappingURL=bundle.js.map', ''));
writeFile(
- "artifacts/sdk.js",
- readFile("../../build/bundle.js").replace(
- "//# sourceMappingURL=bundle.js.map",
- ""
- )
- );
- writeFile(
- "artifacts/loader.js",
- readFile("../../src/loader.js").replace(
- "../../build/bundle.js",
- "/base/artifacts/sdk.js"
- )
+ 'artifacts/loader.js',
+ readFile('../../src/loader.js').replace('../../build/bundle.js', '/base/artifacts/sdk.js')
);
writeFile(
- "artifacts/tests.js",
- [
- readFile("polyfills/promise.js"),
- readFile("suites/helpers.js"),
- replacePlaceholders("suites/shell.js"),
- ].join("\n")
+ 'artifacts/tests.js',
+ [readFile('polyfills/promise.js'), readFile('suites/helpers.js'), replacePlaceholders('suites/shell.js')].join('\n')
);
}
@@ -124,12 +95,8 @@ build();
let fileWatcher;
if (isWatchMode) {
fileWatcher = chokidar
- .watch([
- path.resolve(__dirname, "common"),
- path.resolve(__dirname, "subjects"),
- path.resolve(__dirname, "suites"),
- ])
- .on("change", build);
+ .watch([path.resolve(__dirname, 'common'), path.resolve(__dirname, 'subjects'), path.resolve(__dirname, 'suites')])
+ .on('change', build);
}
const karmaConfigOverrides = {
@@ -143,14 +110,8 @@ const karmaConfigOverrides = {
}),
};
-new karma.Server(
- karma.config.parseConfig(
- path.resolve(__dirname, "karma.conf.js"),
- karmaConfigOverrides
- ),
- exitCode => {
- rmdir("artifacts");
- if (fileWatcher) fileWatcher.close();
- process.exit(exitCode);
- }
-).start();
+new karma.Server(karma.config.parseConfig(path.resolve(__dirname, 'karma.conf.js'), karmaConfigOverrides), exitCode => {
+ rmdir('artifacts');
+ if (fileWatcher) fileWatcher.close();
+ process.exit(exitCode);
+}).start();
diff --git a/packages/browser/test/integration/subjects/console-logs.js b/packages/browser/test/integration/subjects/console-logs.js
index f00a3134ab2f..d32f1a5e1080 100644
--- a/packages/browser/test/integration/subjects/console-logs.js
+++ b/packages/browser/test/integration/subjects/console-logs.js
@@ -1,13 +1,13 @@
-console.log("One");
-console.warn("Two", { a: 1 });
-console.error("Error 2", { b: { c: [] } });
+console.log('One');
+console.warn('Two', { a: 1 });
+console.error('Error 2', { b: { c: [] } });
// Passed assertions _should not_ be captured
-console.assert(1 + 1 === 2, "math works");
+console.assert(1 + 1 === 2, 'math works');
// Failed assertions _should_ be captured
-console.assert(1 + 1 === 3, "math broke");
+console.assert(1 + 1 === 3, 'math broke');
function a() {
- throw new Error("Error thrown 3");
+ throw new Error('Error thrown 3');
}
a();
diff --git a/packages/browser/test/integration/subjects/throw-error.js b/packages/browser/test/integration/subjects/throw-error.js
index 32076658cc45..4ba4f3415da1 100644
--- a/packages/browser/test/integration/subjects/throw-error.js
+++ b/packages/browser/test/integration/subjects/throw-error.js
@@ -1,4 +1,4 @@
function throwRealError() {
- throw new Error("realError");
+ throw new Error('realError');
}
throwRealError();
diff --git a/packages/browser/test/integration/subjects/throw-object.js b/packages/browser/test/integration/subjects/throw-object.js
index 93a2e9e8248a..e69f1f37d5d6 100644
--- a/packages/browser/test/integration/subjects/throw-object.js
+++ b/packages/browser/test/integration/subjects/throw-object.js
@@ -1,7 +1,7 @@
function throwObjectError() {
// never do this; just making sure Raven.js handles this case
// gracefully
- throw { error: "stuff is broken", somekey: "ok" };
+ throw { error: 'stuff is broken', somekey: 'ok' };
}
throwObjectError();
diff --git a/packages/browser/test/integration/subjects/throw-string.js b/packages/browser/test/integration/subjects/throw-string.js
index 9e0dfc04aa75..7429303cab1a 100644
--- a/packages/browser/test/integration/subjects/throw-string.js
+++ b/packages/browser/test/integration/subjects/throw-string.js
@@ -1,5 +1,5 @@
function throwStringError() {
- throw "stringError";
+ throw 'stringError';
}
throwStringError();
diff --git a/packages/browser/test/integration/suites/api.js b/packages/browser/test/integration/suites/api.js
index f3369f1baf8b..f51928c5bed5 100644
--- a/packages/browser/test/integration/suites/api.js
+++ b/packages/browser/test/integration/suites/api.js
@@ -1,126 +1,105 @@
-describe("API", function() {
- it("should capture Sentry.captureMessage", function() {
- return runInSandbox(sandbox, function() {
- Sentry.captureMessage("Hello");
- }).then(function(summary) {
- assert.equal(summary.events[0].message, "Hello");
+describe('API', function () {
+ it('should capture Sentry.captureMessage', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.captureMessage('Hello');
+ }).then(function (summary) {
+ assert.equal(summary.events[0].message, 'Hello');
});
});
- it("should capture Sentry.captureException", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture Sentry.captureException', function () {
+ return runInSandbox(sandbox, function () {
try {
foo();
} catch (e) {
Sentry.captureException(e);
}
- }).then(function(summary) {
- assert.isAtLeast(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 2
- );
- assert.isAtMost(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 4
- );
+ }).then(function (summary) {
+ assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 2);
+ assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 4);
});
});
- it("should capture Sentry internal event as breadcrumbs for the following event sent", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should capture Sentry internal event as breadcrumbs for the following event sent', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
window.allowSentryBreadcrumbs = true;
- Sentry.captureMessage("a");
- Sentry.captureMessage("b");
+ Sentry.captureMessage('a');
+ Sentry.captureMessage('b');
// For the loader
Sentry.flush && Sentry.flush(2000);
window.finalizeManualTest();
- }).then(function(summary) {
+ }).then(function (summary) {
assert.equal(summary.events.length, 2);
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(summary.events[1].breadcrumbs[0].category, "sentry.event");
- assert.equal(
- summary.events[1].breadcrumbs[0].event_id,
- summary.events[0].event_id
- );
- assert.equal(
- summary.events[1].breadcrumbs[0].level,
- summary.events[0].level
- );
+ assert.equal(summary.events[1].breadcrumbs[0].category, 'sentry.event');
+ assert.equal(summary.events[1].breadcrumbs[0].event_id, summary.events[0].event_id);
+ assert.equal(summary.events[1].breadcrumbs[0].level, summary.events[0].level);
});
});
- it("should capture Sentry internal transaction as breadcrumbs for the following event sent", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should capture Sentry internal transaction as breadcrumbs for the following event sent', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
window.allowSentryBreadcrumbs = true;
Sentry.captureEvent({
- event_id: "aa3ff046696b4bc6b609ce6d28fde9e2",
- message: "someMessage",
- transaction: "wat",
- type: "transaction",
+ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2',
+ message: 'someMessage',
+ transaction: 'wat',
+ type: 'transaction',
});
- Sentry.captureMessage("c");
+ Sentry.captureMessage('c');
// For the loader
Sentry.flush && Sentry.flush(2000);
window.finalizeManualTest();
- }).then(function(summary) {
+ }).then(function (summary) {
// We have a length of one here since transactions don't go through beforeSend
// and we add events to summary in beforeSend
assert.equal(summary.events.length, 1);
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(
- summary.events[0].breadcrumbs[0].category,
- "sentry.transaction"
- );
+ assert.equal(summary.events[0].breadcrumbs[0].category, 'sentry.transaction');
assert.isNotEmpty(summary.events[0].breadcrumbs[0].event_id);
assert.isUndefined(summary.events[0].breadcrumbs[0].level);
});
});
- it("should generate a synthetic trace for captureException w/ non-errors", function() {
- return runInSandbox(sandbox, function() {
+ it('should generate a synthetic trace for captureException w/ non-errors', function () {
+ return runInSandbox(sandbox, function () {
throwNonError();
- }).then(function(summary) {
+ }).then(function (summary) {
assert.isAtLeast(summary.events[0].stacktrace.frames.length, 1);
assert.isAtMost(summary.events[0].stacktrace.frames.length, 3);
});
});
- it("should have correct stacktrace order", function() {
- return runInSandbox(sandbox, function() {
+ it('should have correct stacktrace order', function () {
+ return runInSandbox(sandbox, function () {
try {
foo();
} catch (e) {
Sentry.captureException(e);
}
- }).then(function(summary) {
+ }).then(function (summary) {
assert.equal(
summary.events[0].exception.values[0].stacktrace.frames[
summary.events[0].exception.values[0].stacktrace.frames.length - 1
].function,
- "bar"
- );
- assert.isAtLeast(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 2
- );
- assert.isAtMost(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 4
+ 'bar'
);
+ assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 2);
+ assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 4);
});
});
- it("should have exception with type and value", function() {
- return runInSandbox(sandbox, function() {
- Sentry.captureException("this is my test exception");
- }).then(function(summary) {
+ it('should have exception with type and value', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.captureException('this is my test exception');
+ }).then(function (summary) {
assert.isNotEmpty(summary.events[0].exception.values[0].value);
assert.isNotEmpty(summary.events[0].exception.values[0].type);
});
});
- it("should reject duplicate, back-to-back errors from captureException", function() {
- return runInSandbox(sandbox, function() {
+ it('should reject duplicate, back-to-back errors from captureException', function () {
+ return runInSandbox(sandbox, function () {
// Different exceptions, don't dedupe
for (var i = 0; i < 2; i++) {
throwRandomError();
@@ -132,24 +111,18 @@ describe("API", function() {
}
// Same exceptions, different stacktrace (different line number), don't dedupe
- throwSameConsecutiveErrors("bar");
- }).then(function(summary) {
- assert.match(
- summary.events[0].exception.values[0].value,
- /Exception no \d+/
- );
- assert.match(
- summary.events[1].exception.values[0].value,
- /Exception no \d+/
- );
- assert.equal(summary.events[2].exception.values[0].value, "foo");
- assert.equal(summary.events[3].exception.values[0].value, "bar");
- assert.equal(summary.events[4].exception.values[0].value, "bar");
+ throwSameConsecutiveErrors('bar');
+ }).then(function (summary) {
+ assert.match(summary.events[0].exception.values[0].value, /Exception no \d+/);
+ assert.match(summary.events[1].exception.values[0].value, /Exception no \d+/);
+ assert.equal(summary.events[2].exception.values[0].value, 'foo');
+ assert.equal(summary.events[3].exception.values[0].value, 'bar');
+ assert.equal(summary.events[4].exception.values[0].value, 'bar');
});
});
- it("should not reject back-to-back errors with different stack traces", function() {
- return runInSandbox(sandbox, function() {
+ it('should not reject back-to-back errors with different stack traces', function () {
+ return runInSandbox(sandbox, function () {
// same error message, but different stacks means that these are considered
// different errors
@@ -178,28 +151,19 @@ describe("API", function() {
} catch (e) {
Sentry.captureException(e);
}
- }).then(function(summary) {
+ }).then(function (summary) {
// NOTE: regex because exact error message differs per-browser
assert.match(summary.events[0].exception.values[0].value, /baz/);
- assert.equal(
- summary.events[0].exception.values[0].type,
- "ReferenceError"
- );
+ assert.equal(summary.events[0].exception.values[0].type, 'ReferenceError');
assert.match(summary.events[1].exception.values[0].value, /baz/);
- assert.equal(
- summary.events[1].exception.values[0].type,
- "ReferenceError"
- );
+ assert.equal(summary.events[1].exception.values[0].type, 'ReferenceError');
assert.match(summary.events[2].exception.values[0].value, /baz/);
- assert.equal(
- summary.events[2].exception.values[0].type,
- "ReferenceError"
- );
+ assert.equal(summary.events[2].exception.values[0].type, 'ReferenceError');
});
});
- it("should reject duplicate, back-to-back messages from captureMessage", function() {
- return runInSandbox(sandbox, function() {
+ it('should reject duplicate, back-to-back messages from captureMessage', function () {
+ return runInSandbox(sandbox, function () {
// Different messages, don't dedupe
for (var i = 0; i < 2; i++) {
captureRandomMessage();
@@ -207,26 +171,19 @@ describe("API", function() {
// Same messages and same stacktrace, dedupe
for (var j = 0; j < 2; j++) {
- captureMessage("same message, same stacktrace");
+ captureMessage('same message, same stacktrace');
}
// Same messages, different stacktrace (different line number), don't dedupe
- captureSameConsecutiveMessages("same message, different stacktrace");
- }).then(function(summary) {
+ captureSameConsecutiveMessages('same message, different stacktrace');
+ }).then(function (summary) {
// On the async loader since we replay all messages from the same location,
// so we actually only receive 4 summary.events
assert.match(summary.events[0].message, /Message no \d+/);
assert.match(summary.events[1].message, /Message no \d+/);
- assert.equal(summary.events[2].message, "same message, same stacktrace");
- assert.equal(
- summary.events[3].message,
- "same message, different stacktrace"
- );
- !IS_LOADER &&
- assert.equal(
- summary.events[4].message,
- "same message, different stacktrace"
- );
+ assert.equal(summary.events[2].message, 'same message, same stacktrace');
+ assert.equal(summary.events[3].message, 'same message, different stacktrace');
+ !IS_LOADER && assert.equal(summary.events[4].message, 'same message, different stacktrace');
});
});
});
diff --git a/packages/browser/test/integration/suites/breadcrumbs.js b/packages/browser/test/integration/suites/breadcrumbs.js
index 3ca054bf4e95..434bcacc8b4a 100644
--- a/packages/browser/test/integration/suites/breadcrumbs.js
+++ b/packages/browser/test/integration/suites/breadcrumbs.js
@@ -1,311 +1,270 @@
-describe("breadcrumbs", function() {
- it(
- optional("should record an XMLHttpRequest with a handler", IS_LOADER),
- function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "/base/subjects/example.json");
- xhr.onreadystatechange = function() {};
- xhr.send();
- waitForXHR(xhr, function() {
- Sentry.captureMessage("test");
- window.finalizeManualTest();
- });
- }).then(function(summary) {
- // The async loader doesn't wrap XHR
- if (IS_LOADER) {
- return;
- }
- assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
+describe('breadcrumbs', function () {
+ it(optional('should record an XMLHttpRequest with a handler', IS_LOADER), function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', '/base/subjects/example.json');
+ xhr.onreadystatechange = function () {};
+ xhr.send();
+ waitForXHR(xhr, function () {
+ Sentry.captureMessage('test');
+ window.finalizeManualTest();
});
- }
- );
+ }).then(function (summary) {
+ // The async loader doesn't wrap XHR
+ if (IS_LOADER) {
+ return;
+ }
+ assert.equal(summary.breadcrumbs.length, 1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ });
+ });
- it(
- optional(
- "should record an XMLHttpRequest with a handler attached after send was called",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "/base/subjects/example.json");
- xhr.send();
- xhr.onreadystatechange = function() {
- window.handlerCalled = true;
- };
- waitForXHR(xhr, function() {
- Sentry.captureMessage("test");
- window.finalizeManualTest();
- });
- }).then(function(summary) {
- // The async loader doesn't wrap XHR
- if (IS_LOADER) {
- return;
- }
- assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.typeOf(summary.breadcrumbs[0].timestamp, "number");
- assert.isTrue(summary.window.handlerCalled);
- delete summary.window.handlerCalled;
+ it(optional('should record an XMLHttpRequest with a handler attached after send was called', IS_LOADER), function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', '/base/subjects/example.json');
+ xhr.send();
+ xhr.onreadystatechange = function () {
+ window.handlerCalled = true;
+ };
+ waitForXHR(xhr, function () {
+ Sentry.captureMessage('test');
+ window.finalizeManualTest();
});
- }
- );
+ }).then(function (summary) {
+ // The async loader doesn't wrap XHR
+ if (IS_LOADER) {
+ return;
+ }
+ assert.equal(summary.breadcrumbs.length, 1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.typeOf(summary.breadcrumbs[0].timestamp, 'number');
+ assert.isTrue(summary.window.handlerCalled);
+ delete summary.window.handlerCalled;
+ });
+ });
- it(
- optional(
- "should record an XMLHttpRequest without any handlers set",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- var xhr = new XMLHttpRequest();
- xhr.open("get", "/base/subjects/example.json");
- xhr.send();
- waitForXHR(xhr, function() {
- Sentry.captureMessage("test");
- window.finalizeManualTest();
- });
- }).then(function(summary) {
- // The async loader doesn't wrap XHR
- if (IS_LOADER) {
- return;
- }
- assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.isUndefined(summary.breadcrumbs[0].data.input);
- // To make sure that we are not providing this key for non-post requests
- assert.equal(summary.breadcrumbHints[0].input, undefined);
+ it(optional('should record an XMLHttpRequest without any handlers set', IS_LOADER), function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open('get', '/base/subjects/example.json');
+ xhr.send();
+ waitForXHR(xhr, function () {
+ Sentry.captureMessage('test');
+ window.finalizeManualTest();
});
- }
- );
+ }).then(function (summary) {
+ // The async loader doesn't wrap XHR
+ if (IS_LOADER) {
+ return;
+ }
+ assert.equal(summary.breadcrumbs.length, 1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.isUndefined(summary.breadcrumbs[0].data.input);
+ // To make sure that we are not providing this key for non-post requests
+ assert.equal(summary.breadcrumbHints[0].input, undefined);
+ });
+ });
- it(
- optional(
- "should give access to request body for XMLHttpRequest POST requests",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- var xhr = new XMLHttpRequest();
- xhr.open("POST", "/base/subjects/example.json");
- xhr.send('{"foo":"bar"}');
- waitForXHR(xhr, function() {
- Sentry.captureMessage("test");
- window.finalizeManualTest();
- });
- }).then(function(summary) {
- // The async loader doesn't wrap XHR
- if (IS_LOADER) {
- return;
- }
- assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "POST");
- assert.isUndefined(summary.breadcrumbs[0].data.input);
- assert.equal(summary.breadcrumbHints[0].input, '{"foo":"bar"}');
+ it(optional('should give access to request body for XMLHttpRequest POST requests', IS_LOADER), function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', '/base/subjects/example.json');
+ xhr.send('{"foo":"bar"}');
+ waitForXHR(xhr, function () {
+ Sentry.captureMessage('test');
+ window.finalizeManualTest();
});
- }
- );
+ }).then(function (summary) {
+ // The async loader doesn't wrap XHR
+ if (IS_LOADER) {
+ return;
+ }
+ assert.equal(summary.breadcrumbs.length, 1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'POST');
+ assert.isUndefined(summary.breadcrumbs[0].data.input);
+ assert.equal(summary.breadcrumbHints[0].input, '{"foo":"bar"}');
+ });
+ });
- it("should record a fetch request", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- fetch("/base/subjects/example.json", {
- method: "Get",
+ it('should record a fetch request', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ fetch('/base/subjects/example.json', {
+ method: 'Get',
})
.then(
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
},
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
}
)
- .then(function() {
+ .then(function () {
window.finalizeManualTest();
})
- .catch(function() {
+ .catch(function () {
window.finalizeManualTest();
});
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
if (summary.window.supportsNativeFetch()) {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "fetch");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.equal(
- summary.breadcrumbs[0].data.url,
- "/base/subjects/example.json"
- );
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'fetch');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.equal(summary.breadcrumbs[0].data.url, '/base/subjects/example.json');
} else {
// otherwise we use a fetch polyfill based on xhr
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.equal(
- summary.breadcrumbs[0].data.url,
- "/base/subjects/example.json"
- );
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.equal(summary.breadcrumbs[0].data.url, '/base/subjects/example.json');
}
}
});
});
- it("should record a fetch request with Request obj instead of URL string", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- fetch(new Request("/base/subjects/example.json"))
+ it('should record a fetch request with Request obj instead of URL string', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ fetch(new Request('/base/subjects/example.json'))
.then(
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
},
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
}
)
- .then(function() {
+ .then(function () {
window.finalizeManualTest();
})
- .catch(function() {
+ .catch(function () {
window.finalizeManualTest();
});
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
if (summary.window.supportsNativeFetch()) {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "fetch");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'fetch');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
// Request constructor normalizes the url
- assert.ok(
- summary.breadcrumbs[0].data.url.indexOf(
- "/base/subjects/example.json"
- ) !== -1
- );
+ assert.ok(summary.breadcrumbs[0].data.url.indexOf('/base/subjects/example.json') !== -1);
} else {
// otherwise we use a fetch polyfill based on xhr
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.ok(
- summary.breadcrumbs[0].data.url.indexOf(
- "/base/subjects/example.json"
- ) !== -1
- );
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.ok(summary.breadcrumbs[0].data.url.indexOf('/base/subjects/example.json') !== -1);
}
}
});
});
- it("should record a fetch request with an arbitrary type argument", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should record a fetch request with an arbitrary type argument', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
fetch(123)
.then(
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
},
- function() {
- Sentry.captureMessage("test");
+ function () {
+ Sentry.captureMessage('test');
}
)
- .then(function() {
+ .then(function () {
window.finalizeManualTest();
})
- .catch(function() {
+ .catch(function () {
window.finalizeManualTest();
});
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap fetch, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
if (summary.window.supportsNativeFetch()) {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "fetch");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.ok(summary.breadcrumbs[0].data.url.indexOf("123") !== -1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'fetch');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.ok(summary.breadcrumbs[0].data.url.indexOf('123') !== -1);
} else {
// otherwise we use a fetch polyfill based on xhr
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].type, "http");
- assert.equal(summary.breadcrumbs[0].category, "xhr");
- assert.equal(summary.breadcrumbs[0].data.method, "GET");
- assert.ok(summary.breadcrumbs[0].data.url.indexOf("123") !== -1);
+ assert.equal(summary.breadcrumbs[0].type, 'http');
+ assert.equal(summary.breadcrumbs[0].category, 'xhr');
+ assert.equal(summary.breadcrumbs[0].data.method, 'GET');
+ assert.ok(summary.breadcrumbs[0].data.url.indexOf('123') !== -1);
}
}
});
});
- it("should provide a hint for dom events that includes event name and event itself", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
- var clickHandler = function() {};
- input.addEventListener("click", clickHandler);
- var click = new MouseEvent("click");
+ it('should provide a hint for dom events that includes event name and event itself', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
+ var clickHandler = function () {};
+ input.addEventListener('click', clickHandler);
+ var click = new MouseEvent('click');
input.dispatchEvent(click);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbHints.length, 1);
- assert.equal(summary.breadcrumbHints[0].name, "click");
- assert.equal(summary.breadcrumbHints[0].event.target.tagName, "INPUT");
+ assert.equal(summary.breadcrumbHints[0].name, 'click');
+ assert.equal(summary.breadcrumbHints[0].event.target.tagName, 'INPUT');
// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
}
});
});
- it("should not fail with click or keypress handler with no callback", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
- input.addEventListener("click", undefined);
- input.addEventListener("keypress", undefined);
+ it('should not fail with click or keypress handler with no callback', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
+ input.addEventListener('click', undefined);
+ input.addEventListener('keypress', undefined);
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
input.dispatchEvent(click);
- var keypress = new KeyboardEvent("keypress");
+ var keypress = new KeyboardEvent('keypress');
input.dispatchEvent(keypress);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
- assert.equal(summary.breadcrumbs[1].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[1].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[1].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > input[name="foo"]');
// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
@@ -313,18 +272,18 @@ describe("breadcrumbs", function() {
});
});
- it("should not fail with custom event", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
- input.addEventListener("build", function(evt) {
+ it('should not fail with custom event', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
+ input.addEventListener('build', function (evt) {
evt.stopPropagation();
});
- var customEvent = new CustomEvent("build", { detail: 1 });
+ var customEvent = new CustomEvent('build', { detail: 1 });
input.dispatchEvent(customEvent);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
@@ -336,16 +295,16 @@ describe("breadcrumbs", function() {
});
});
- it("should not fail with custom event and handler with no callback", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
- input.addEventListener("build", undefined);
+ it('should not fail with custom event and handler with no callback', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
+ input.addEventListener('build', undefined);
- var customEvent = new CustomEvent("build", { detail: 1 });
+ var customEvent = new CustomEvent('build', { detail: 1 });
input.dispatchEvent(customEvent);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
@@ -357,178 +316,160 @@ describe("breadcrumbs", function() {
});
});
- it("should record a mouse click on element WITH click handler present", function() {
- return runInSandbox(sandbox, function() {
+ it('should record a mouse click on element WITH click handler present', function () {
+ return runInSandbox(sandbox, function () {
// add an event listener to the input. we want to make sure that
// our breadcrumbs still work even if the page has an event listener
// on an element that cancels event bubbling
- var input = document.getElementsByTagName("input")[0];
- var clickHandler = function(evt) {
+ var input = document.getElementsByTagName('input')[0];
+ var clickHandler = function (evt) {
evt.stopPropagation(); // don't bubble
};
- input.addEventListener("click", clickHandler);
+ input.addEventListener('click', clickHandler);
// click
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
input.dispatchEvent(click);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
}
});
});
- it("should record a mouse click on element WITHOUT click handler present", function() {
- return runInSandbox(sandbox, function() {
+ it('should record a mouse click on element WITHOUT click handler present', function () {
+ return runInSandbox(sandbox, function () {
// click
- var click = new MouseEvent("click");
- var input = document.getElementsByTagName("input")[0];
+ var click = new MouseEvent('click');
+ var input = document.getElementsByTagName('input')[0];
input.dispatchEvent(click);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
}
});
});
- it("should only record a SINGLE mouse click for a tree of elements with event listeners", function() {
- return runInSandbox(sandbox, function() {
- var clickHandler = function() {};
+ it('should only record a SINGLE mouse click for a tree of elements with event listeners', function () {
+ return runInSandbox(sandbox, function () {
+ var clickHandler = function () {};
// mousemove event shouldnt clobber subsequent "breadcrumbed" events (see #724)
- document.querySelector(".a").addEventListener("mousemove", clickHandler);
+ document.querySelector('.a').addEventListener('mousemove', clickHandler);
- document.querySelector(".a").addEventListener("click", clickHandler);
- document.querySelector(".b").addEventListener("click", clickHandler);
- document.querySelector(".c").addEventListener("click", clickHandler);
+ document.querySelector('.a').addEventListener('click', clickHandler);
+ document.querySelector('.b').addEventListener('click', clickHandler);
+ document.querySelector('.c').addEventListener('click', clickHandler);
// click
- var click = new MouseEvent("click");
- var input = document.querySelector(".a"); // leaf node
+ var click = new MouseEvent('click');
+ var input = document.querySelector('.a'); // leaf node
input.dispatchEvent(click);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- "body > div.c > div.b > div.a"
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > div.c > div.b > div.a');
}
});
});
- it("should bail out if accessing the `target` property of an event throws an exception", function() {
+ it('should bail out if accessing the `target` property of an event throws an exception', function () {
// see: https://github.com/getsentry/sentry-javascript/issues/768
- return runInSandbox(sandbox, function() {
+ return runInSandbox(sandbox, function () {
// click
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
function kaboom() {
- throw new Error("lol");
+ throw new Error('lol');
}
- Object.defineProperty(click, "target", { get: kaboom });
+ Object.defineProperty(click, 'target', { get: kaboom });
- var input = document.querySelector(".a"); // leaf node
+ var input = document.querySelector('.a'); // leaf node
- Sentry.captureMessage("test");
+ Sentry.captureMessage('test');
input.dispatchEvent(click);
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(summary.breadcrumbs[0].message, "");
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, '');
}
});
});
- it('should record consecutive keypress events into a single "input" breadcrumb', function() {
- return runInSandbox(sandbox, function() {
+ it('should record consecutive keypress events into a single "input" breadcrumb', function () {
+ return runInSandbox(sandbox, function () {
// keypress twice
- var keypress1 = new KeyboardEvent("keypress");
- var keypress2 = new KeyboardEvent("keypress");
+ var keypress1 = new KeyboardEvent('keypress');
+ var keypress2 = new KeyboardEvent('keypress');
- var input = document.getElementsByTagName("input")[0];
+ var input = document.getElementsByTagName('input')[0];
input.dispatchEvent(keypress1);
input.dispatchEvent(keypress2);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
}
});
});
- it("should correctly capture multiple consecutive breadcrumbs if they are of different type", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
+ it('should correctly capture multiple consecutive breadcrumbs if they are of different type', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
- var clickHandler = function() {};
- input.addEventListener("click", clickHandler);
- var keypressHandler = function() {};
- input.addEventListener("keypress", keypressHandler);
+ var clickHandler = function () {};
+ input.addEventListener('click', clickHandler);
+ var keypressHandler = function () {};
+ input.addEventListener('keypress', keypressHandler);
- input.dispatchEvent(new MouseEvent("click"));
- input.dispatchEvent(new KeyboardEvent("keypress"));
+ input.dispatchEvent(new MouseEvent('click'));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
// Breadcrumb should be captured by the global event listeners, not a specific one
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
- assert.equal(summary.breadcrumbs[1].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
+ assert.equal(summary.breadcrumbs[1].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
@@ -536,40 +477,34 @@ describe("breadcrumbs", function() {
});
});
- it("should debounce multiple consecutive identical breadcrumbs but allow for switching to a different type", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
+ it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different type', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
- var clickHandler = function() {};
- input.addEventListener("click", clickHandler);
- var keypressHandler = function() {};
- input.addEventListener("keypress", keypressHandler);
+ var clickHandler = function () {};
+ input.addEventListener('click', clickHandler);
+ var keypressHandler = function () {};
+ input.addEventListener('keypress', keypressHandler);
- input.dispatchEvent(new MouseEvent("click"));
- input.dispatchEvent(new MouseEvent("click"));
- input.dispatchEvent(new MouseEvent("click"));
- input.dispatchEvent(new KeyboardEvent("keypress"));
- input.dispatchEvent(new KeyboardEvent("keypress"));
- input.dispatchEvent(new KeyboardEvent("keypress"));
+ input.dispatchEvent(new MouseEvent('click'));
+ input.dispatchEvent(new MouseEvent('click'));
+ input.dispatchEvent(new MouseEvent('click'));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
// Breadcrumb should be captured by the global event listeners, not a specific one
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
- assert.equal(summary.breadcrumbs[1].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
+ assert.equal(summary.breadcrumbs[1].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
@@ -577,36 +512,30 @@ describe("breadcrumbs", function() {
});
});
- it("should debounce multiple consecutive identical breadcrumbs but allow for switching to a different target", function() {
- return runInSandbox(sandbox, function() {
- var input = document.querySelector("#foo-form input");
- var div = document.querySelector("#foo-form div");
+ it('should debounce multiple consecutive identical breadcrumbs but allow for switching to a different target', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.querySelector('#foo-form input');
+ var div = document.querySelector('#foo-form div');
- var clickHandler = function() {};
- input.addEventListener("click", clickHandler);
- div.addEventListener("click", clickHandler);
+ var clickHandler = function () {};
+ input.addEventListener('click', clickHandler);
+ div.addEventListener('click', clickHandler);
- input.dispatchEvent(new MouseEvent("click"));
- div.dispatchEvent(new MouseEvent("click"));
+ input.dispatchEvent(new MouseEvent('click'));
+ div.dispatchEvent(new MouseEvent('click'));
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
// Breadcrumb should be captured by the global event listeners, not a specific one
assert.equal(summary.breadcrumbs.length, 2);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
- assert.equal(summary.breadcrumbs[1].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[1].message,
- "body > form#foo-form > div.contenteditable"
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
+ assert.equal(summary.breadcrumbs[1].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > div.contenteditable');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
@@ -614,188 +543,161 @@ describe("breadcrumbs", function() {
});
});
- it(
- optional(
- "should flush keypress breadcrumbs when an error is thrown",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, function() {
- // keypress
- var keypress = new KeyboardEvent("keypress");
- var input = document.getElementsByTagName("input")[0];
- input.dispatchEvent(keypress);
- foo(); // throw exception
- }).then(function(summary) {
- if (IS_LOADER) {
- return;
- }
- // TODO: don't really understand what's going on here
- // Why do we not catch an error here
+ it(optional('should flush keypress breadcrumbs when an error is thrown', IS_LOADER), function () {
+ return runInSandbox(sandbox, function () {
+ // keypress
+ var keypress = new KeyboardEvent('keypress');
+ var input = document.getElementsByTagName('input')[0];
+ input.dispatchEvent(keypress);
+ foo(); // throw exception
+ }).then(function (summary) {
+ if (IS_LOADER) {
+ return;
+ }
+ // TODO: don't really understand what's going on here
+ // Why do we not catch an error here
- assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
- });
- }
- );
+ assert.equal(summary.breadcrumbs.length, 1);
+ assert.equal(summary.breadcrumbs[0].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
+ });
+ });
- it("should flush keypress breadcrumb when input event occurs immediately after", function() {
- return runInSandbox(sandbox, function() {
+ it('should flush keypress breadcrumb when input event occurs immediately after', function () {
+ return runInSandbox(sandbox, function () {
// 1st keypress
- var keypress1 = new KeyboardEvent("keypress");
+ var keypress1 = new KeyboardEvent('keypress');
// click
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
// 2nd keypress
- var keypress2 = new KeyboardEvent("keypress");
+ var keypress2 = new KeyboardEvent('keypress');
- var input = document.getElementsByTagName("input")[0];
+ var input = document.getElementsByTagName('input')[0];
input.dispatchEvent(keypress1);
input.dispatchEvent(click);
input.dispatchEvent(keypress2);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 3);
- assert.equal(summary.breadcrumbs[0].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
-
- assert.equal(summary.breadcrumbs[1].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[1].message,
- 'body > form#foo-form > input[name="foo"]'
- );
-
- assert.equal(summary.breadcrumbs[2].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[2].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
+
+ assert.equal(summary.breadcrumbs[1].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > input[name="foo"]');
+
+ assert.equal(summary.breadcrumbs[2].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[2].message, 'body > form#foo-form > input[name="foo"]');
}
});
});
- it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', function() {
- return runInSandbox(sandbox, function() {
+ it('should record consecutive keypress events in a contenteditable into a single "input" breadcrumb', function () {
+ return runInSandbox(sandbox, function () {
// keypress twice
- var keypress1 = new KeyboardEvent("keypress");
- var keypress2 = new KeyboardEvent("keypress");
+ var keypress1 = new KeyboardEvent('keypress');
+ var keypress2 = new KeyboardEvent('keypress');
- var div = document.querySelector("[contenteditable]");
+ var div = document.querySelector('[contenteditable]');
div.dispatchEvent(keypress1);
div.dispatchEvent(keypress2);
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- "body > form#foo-form > div.contenteditable"
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > div.contenteditable');
}
});
});
- it("should record click events that were handled using an object with handleEvent property and call original callback", function() {
- return runInSandbox(sandbox, function() {
+ it('should record click events that were handled using an object with handleEvent property and call original callback', function () {
+ return runInSandbox(sandbox, function () {
window.handleEventCalled = false;
- var input = document.getElementsByTagName("input")[0];
- input.addEventListener("click", {
- handleEvent: function() {
+ var input = document.getElementsByTagName('input')[0];
+ input.addEventListener('click', {
+ handleEvent: function () {
window.handleEventCalled = true;
},
});
- input.dispatchEvent(new MouseEvent("click"));
+ input.dispatchEvent(new MouseEvent('click'));
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.click");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.click');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.window.handleEventCalled, true);
}
});
});
- it("should record keypress events that were handled using an object with handleEvent property and call original callback", function() {
- return runInSandbox(sandbox, function() {
+ it('should record keypress events that were handled using an object with handleEvent property and call original callback', function () {
+ return runInSandbox(sandbox, function () {
window.handleEventCalled = false;
- var input = document.getElementsByTagName("input")[0];
- input.addEventListener("keypress", {
- handleEvent: function() {
+ var input = document.getElementsByTagName('input')[0];
+ input.addEventListener('keypress', {
+ handleEvent: function () {
window.handleEventCalled = true;
},
});
- input.dispatchEvent(new KeyboardEvent("keypress"));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
assert.equal(summary.breadcrumbs.length, 1);
- assert.equal(summary.breadcrumbs[0].category, "ui.input");
- assert.equal(
- summary.breadcrumbs[0].message,
- 'body > form#foo-form > input[name="foo"]'
- );
+ assert.equal(summary.breadcrumbs[0].category, 'ui.input');
+ assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.window.handleEventCalled, true);
}
});
});
- it("should remove breadcrumb instrumentation when all event listeners are detached", function() {
- return runInSandbox(sandbox, function() {
- var input = document.getElementsByTagName("input")[0];
-
- var clickHandler = function() {};
- var otherClickHandler = function() {};
- input.addEventListener("click", clickHandler);
- input.addEventListener("click", otherClickHandler);
- input.removeEventListener("click", clickHandler);
- input.removeEventListener("click", otherClickHandler);
-
- var keypressHandler = function() {};
- var otherKeypressHandler = function() {};
- input.addEventListener("keypress", keypressHandler);
- input.addEventListener("keypress", otherKeypressHandler);
- input.removeEventListener("keypress", keypressHandler);
- input.removeEventListener("keypress", otherKeypressHandler);
-
- input.dispatchEvent(new MouseEvent("click"));
- input.dispatchEvent(new KeyboardEvent("keypress"));
-
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ it('should remove breadcrumb instrumentation when all event listeners are detached', function () {
+ return runInSandbox(sandbox, function () {
+ var input = document.getElementsByTagName('input')[0];
+
+ var clickHandler = function () {};
+ var otherClickHandler = function () {};
+ input.addEventListener('click', clickHandler);
+ input.addEventListener('click', otherClickHandler);
+ input.removeEventListener('click', clickHandler);
+ input.removeEventListener('click', otherClickHandler);
+
+ var keypressHandler = function () {};
+ var otherKeypressHandler = function () {};
+ input.addEventListener('keypress', keypressHandler);
+ input.addEventListener('keypress', otherKeypressHandler);
+ input.removeEventListener('keypress', keypressHandler);
+ input.removeEventListener('keypress', otherKeypressHandler);
+
+ input.dispatchEvent(new MouseEvent('click'));
+ input.dispatchEvent(new KeyboardEvent('keypress'));
+
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
@@ -810,143 +712,87 @@ describe("breadcrumbs", function() {
});
it(
- optional(
- "should record history.[pushState|replaceState] changes as navigation breadcrumbs",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, function() {
- history.pushState({}, "", "/foo");
- history.pushState({}, "", "/bar?a=1#fragment");
- history.pushState({}, "", {}); // pushState calls toString on non-string args
- history.pushState({}, "", null); // does nothing / no-op
+ optional('should record history.[pushState|replaceState] changes as navigation breadcrumbs', IS_LOADER),
+ function () {
+ return runInSandbox(sandbox, function () {
+ history.pushState({}, '', '/foo');
+ history.pushState({}, '', '/bar?a=1#fragment');
+ history.pushState({}, '', {}); // pushState calls toString on non-string args
+ history.pushState({}, '', null); // does nothing / no-op
// can't call history.back() because it will change url of parent document
// (e.g. document running mocha) ... instead just "emulate" a back button
// press by calling replaceState
- history.replaceState({}, "", "/bar?a=1#fragment");
- Sentry.captureMessage("test");
- }).then(function(summary) {
+ history.replaceState({}, '', '/bar?a=1#fragment');
+ Sentry.captureMessage('test');
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap history
return;
}
assert.equal(summary.breadcrumbs.length, 4);
- assert.equal(summary.breadcrumbs[0].category, "navigation"); // (start) => foo
- assert.equal(summary.breadcrumbs[1].category, "navigation"); // foo => bar?a=1#fragment
- assert.equal(summary.breadcrumbs[2].category, "navigation"); // bar?a=1#fragment => [object%20Object]
- assert.equal(summary.breadcrumbs[3].category, "navigation"); // [object%20Object] => bar?a=1#fragment (back button)
-
- assert.ok(
- /\/base\/variants\/.*\.html$/.test(summary.breadcrumbs[0].data.from),
- "'from' url is incorrect"
- );
- assert.ok(
- /\/foo$/.test(summary.breadcrumbs[0].data.to),
- "'to' url is incorrect"
- );
-
- assert.ok(
- /\/foo$/.test(summary.breadcrumbs[1].data.from),
- "'from' url is incorrect"
- );
- assert.ok(
- /\/bar\?a=1#fragment$/.test(summary.breadcrumbs[1].data.to),
- "'to' url is incorrect"
- );
-
- assert.ok(
- /\/bar\?a=1#fragment$/.test(summary.breadcrumbs[2].data.from),
- "'from' url is incorrect"
- );
- assert.ok(
- /\[object Object\]$/.test(summary.breadcrumbs[2].data.to),
- "'to' url is incorrect"
- );
-
- assert.ok(
- /\[object Object\]$/.test(summary.breadcrumbs[3].data.from),
- "'from' url is incorrect"
- );
- assert.ok(
- /\/bar\?a=1#fragment/.test(summary.breadcrumbs[3].data.to),
- "'to' url is incorrect"
- );
- });
- }
- );
+ assert.equal(summary.breadcrumbs[0].category, 'navigation'); // (start) => foo
+ assert.equal(summary.breadcrumbs[1].category, 'navigation'); // foo => bar?a=1#fragment
+ assert.equal(summary.breadcrumbs[2].category, 'navigation'); // bar?a=1#fragment => [object%20Object]
+ assert.equal(summary.breadcrumbs[3].category, 'navigation'); // [object%20Object] => bar?a=1#fragment (back button)
- it(
- optional("should preserve native code detection compatibility", IS_LOADER),
- function() {
- return runInSandbox(sandbox, { manual: true }, function() {
- window.resolveTest();
- }).then(function() {
- if (IS_LOADER) {
- // The async loader doesn't wrap anything
- return;
- }
- assert.include(
- Function.prototype.toString.call(window.setTimeout),
- "[native code]"
- );
- assert.include(
- Function.prototype.toString.call(window.setInterval),
- "[native code]"
- );
- assert.include(
- Function.prototype.toString.call(window.addEventListener),
- "[native code]"
- );
- assert.include(
- Function.prototype.toString.call(window.removeEventListener),
- "[native code]"
- );
- assert.include(
- Function.prototype.toString.call(window.requestAnimationFrame),
- "[native code]"
- );
- if ("fetch" in window) {
- assert.include(
- Function.prototype.toString.call(window.fetch),
- "[native code]"
- );
- }
+ assert.ok(/\/base\/variants\/.*\.html$/.test(summary.breadcrumbs[0].data.from), "'from' url is incorrect");
+ assert.ok(/\/foo$/.test(summary.breadcrumbs[0].data.to), "'to' url is incorrect");
+
+ assert.ok(/\/foo$/.test(summary.breadcrumbs[1].data.from), "'from' url is incorrect");
+ assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[1].data.to), "'to' url is incorrect");
+
+ assert.ok(/\/bar\?a=1#fragment$/.test(summary.breadcrumbs[2].data.from), "'from' url is incorrect");
+ assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[2].data.to), "'to' url is incorrect");
+
+ assert.ok(/\[object Object\]$/.test(summary.breadcrumbs[3].data.from), "'from' url is incorrect");
+ assert.ok(/\/bar\?a=1#fragment/.test(summary.breadcrumbs[3].data.to), "'to' url is incorrect");
});
}
);
- it("should capture console breadcrumbs", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it(optional('should preserve native code detection compatibility', IS_LOADER), function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ window.resolveTest();
+ }).then(function () {
+ if (IS_LOADER) {
+ // The async loader doesn't wrap anything
+ return;
+ }
+ assert.include(Function.prototype.toString.call(window.setTimeout), '[native code]');
+ assert.include(Function.prototype.toString.call(window.setInterval), '[native code]');
+ assert.include(Function.prototype.toString.call(window.addEventListener), '[native code]');
+ assert.include(Function.prototype.toString.call(window.removeEventListener), '[native code]');
+ assert.include(Function.prototype.toString.call(window.requestAnimationFrame), '[native code]');
+ if ('fetch' in window) {
+ assert.include(Function.prototype.toString.call(window.fetch), '[native code]');
+ }
+ });
+ });
+
+ it('should capture console breadcrumbs', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
window.allowConsoleBreadcrumbs = true;
- var logs = document.createElement("script");
- logs.src = "/base/subjects/console-logs.js";
- logs.onload = function() {
+ var logs = document.createElement('script');
+ logs.src = '/base/subjects/console-logs.js';
+ logs.onload = function () {
window.finalizeManualTest();
};
document.head.appendChild(logs);
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't capture breadcrumbs, but we should receive the event without them
assert.lengthOf(summary.events, 1);
} else {
- if ("assert" in console) {
+ if ('assert' in console) {
assert.lengthOf(summary.breadcrumbs, 4);
- assert.deepEqual(summary.breadcrumbs[3].data.arguments, [
- "math broke",
- ]);
+ assert.deepEqual(summary.breadcrumbs[3].data.arguments, ['math broke']);
} else {
assert.lengthOf(summary.breadcrumbs, 3);
}
- assert.deepEqual(summary.breadcrumbs[0].data.arguments, ["One"]);
- assert.deepEqual(summary.breadcrumbs[1].data.arguments, [
- "Two",
- { a: 1 },
- ]);
- assert.deepEqual(summary.breadcrumbs[2].data.arguments, [
- "Error 2",
- { b: { c: [] } },
- ]);
+ assert.deepEqual(summary.breadcrumbs[0].data.arguments, ['One']);
+ assert.deepEqual(summary.breadcrumbs[1].data.arguments, ['Two', { a: 1 }]);
+ assert.deepEqual(summary.breadcrumbs[2].data.arguments, ['Error 2', { b: { c: [] } }]);
}
});
});
diff --git a/packages/browser/test/integration/suites/builtins.js b/packages/browser/test/integration/suites/builtins.js
index 2cfc837f27b2..8fa30d120e90 100644
--- a/packages/browser/test/integration/suites/builtins.js
+++ b/packages/browser/test/integration/suites/builtins.js
@@ -1,20 +1,20 @@
-describe("wrapped built-ins", function() {
- it("should capture exceptions from event listeners", function() {
- return runInSandbox(sandbox, function() {
- var div = document.createElement("div");
+describe('wrapped built-ins', function () {
+ it('should capture exceptions from event listeners', function () {
+ return runInSandbox(sandbox, function () {
+ var div = document.createElement('div');
document.body.appendChild(div);
div.addEventListener(
- "click",
- function() {
+ 'click',
+ function () {
window.element = div;
window.context = this;
foo();
},
false
);
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
div.dispatchEvent(click);
- }).then(function(summary) {
+ }).then(function (summary) {
// Make sure we preserve the correct context
assert.equal(summary.window.element, summary.window.context);
delete summary.window.element;
@@ -23,105 +23,105 @@ describe("wrapped built-ins", function() {
});
});
- it("should transparently remove event listeners from wrapped functions", function() {
- return runInSandbox(sandbox, function() {
- var div = document.createElement("div");
+ it('should transparently remove event listeners from wrapped functions', function () {
+ return runInSandbox(sandbox, function () {
+ var div = document.createElement('div');
document.body.appendChild(div);
- var fooFn = function() {
+ var fooFn = function () {
foo();
};
- var barFn = function() {
+ var barFn = function () {
bar();
};
- div.addEventListener("click", fooFn);
- div.addEventListener("click", barFn);
- div.removeEventListener("click", barFn);
- div.dispatchEvent(new MouseEvent("click"));
- }).then(function(summary) {
+ div.addEventListener('click', fooFn);
+ div.addEventListener('click', barFn);
+ div.removeEventListener('click', barFn);
+ div.dispatchEvent(new MouseEvent('click'));
+ }).then(function (summary) {
assert.lengthOf(summary.events, 1);
});
});
- it("should remove the original callback if it was registered before Sentry initialized (w. original method)", function() {
- return runInSandbox(sandbox, function() {
- var div = document.createElement("div");
+ it('should remove the original callback if it was registered before Sentry initialized (w. original method)', function () {
+ return runInSandbox(sandbox, function () {
+ var div = document.createElement('div');
document.body.appendChild(div);
window.capturedCall = false;
- var captureFn = function() {
+ var captureFn = function () {
window.capturedCall = true;
};
// Use original addEventListener to simulate non-wrapped behavior (callback is attached without __sentry_wrapped__)
- window.originalBuiltIns.addEventListener.call(div, "click", captureFn);
+ window.originalBuiltIns.addEventListener.call(div, 'click', captureFn);
// Then attach the same callback again, but with already wrapped method
- div.addEventListener("click", captureFn);
- div.removeEventListener("click", captureFn);
- div.dispatchEvent(new MouseEvent("click"));
- }).then(function(summary) {
+ div.addEventListener('click', captureFn);
+ div.removeEventListener('click', captureFn);
+ div.dispatchEvent(new MouseEvent('click'));
+ }).then(function (summary) {
assert.equal(summary.window.capturedCall, false);
delete summary.window.capturedCalls;
});
});
- it("should capture exceptions inside setTimeout", function() {
- return runInSandbox(sandbox, function() {
- setTimeout(function() {
+ it('should capture exceptions inside setTimeout', function () {
+ return runInSandbox(sandbox, function () {
+ setTimeout(function () {
foo();
});
- }).then(function(summary) {
+ }).then(function (summary) {
assert.match(summary.events[0].exception.values[0].value, /baz/);
});
});
- it("should capture exceptions inside setInterval", function() {
- return runInSandbox(sandbox, function() {
- var exceptionInterval = setInterval(function() {
+ it('should capture exceptions inside setInterval', function () {
+ return runInSandbox(sandbox, function () {
+ var exceptionInterval = setInterval(function () {
clearInterval(exceptionInterval);
foo();
}, 0);
- }).then(function(summary) {
+ }).then(function (summary) {
assert.match(summary.events[0].exception.values[0].value, /baz/);
});
});
- describe("requestAnimationFrame", function() {
- it("should capture exceptions inside callback", function() {
+ describe('requestAnimationFrame', function () {
+ it('should capture exceptions inside callback', function () {
// needs to be visible or requestAnimationFrame won't ever fire
- sandbox.style.display = "block";
+ sandbox.style.display = 'block';
- return runInSandbox(sandbox, { manual: true }, function() {
- requestAnimationFrame(function() {
+ return runInSandbox(sandbox, { manual: true }, function () {
+ requestAnimationFrame(function () {
window.finalizeManualTest();
foo();
});
- }).then(function(summary) {
+ }).then(function (summary) {
assert.match(summary.events[0].exception.values[0].value, /baz/);
});
});
- it("wrapped callback should preserve correct context - window (not-bound)", function() {
+ it('wrapped callback should preserve correct context - window (not-bound)', function () {
// needs to be visible or requestAnimationFrame won't ever fire
- sandbox.style.display = "block";
- return runInSandbox(sandbox, { manual: true }, function() {
- requestAnimationFrame(function() {
+ sandbox.style.display = 'block';
+ return runInSandbox(sandbox, { manual: true }, function () {
+ requestAnimationFrame(function () {
window.capturedCtx = this;
window.finalizeManualTest();
});
- }).then(function(summary) {
+ }).then(function (summary) {
assert.strictEqual(summary.window.capturedCtx, summary.window);
delete summary.window.capturedCtx;
});
});
- it("wrapped callback should preserve correct context - class bound method", function() {
+ it('wrapped callback should preserve correct context - class bound method', function () {
// needs to be visible or requestAnimationFrame won't ever fire
- sandbox.style.display = "block";
- return runInSandbox(sandbox, { manual: true }, function() {
+ sandbox.style.display = 'block';
+ return runInSandbox(sandbox, { manual: true }, function () {
// TypeScript-transpiled class syntax
- var Foo = (function() {
+ var Foo = (function () {
function Foo() {
var _this = this;
this.magicNumber = 42;
- this.getThis = function() {
+ this.getThis = function () {
window.capturedCtx = _this;
window.finalizeManualTest();
};
@@ -130,83 +130,80 @@ describe("wrapped built-ins", function() {
})();
var foo = new Foo();
requestAnimationFrame(foo.getThis);
- }).then(function(summary) {
+ }).then(function (summary) {
assert.strictEqual(summary.window.capturedCtx.magicNumber, 42);
delete summary.window.capturedCtx;
});
});
- it("wrapped callback should preserve correct context - `bind` bound method", function() {
+ it('wrapped callback should preserve correct context - `bind` bound method', function () {
// needs to be visible or requestAnimationFrame won't ever fire
- sandbox.style.display = "block";
- return runInSandbox(sandbox, { manual: true }, function() {
+ sandbox.style.display = 'block';
+ return runInSandbox(sandbox, { manual: true }, function () {
function foo() {
window.capturedCtx = this;
window.finalizeManualTest();
}
requestAnimationFrame(foo.bind({ magicNumber: 42 }));
- }).then(function(summary) {
+ }).then(function (summary) {
assert.strictEqual(summary.window.capturedCtx.magicNumber, 42);
delete summary.window.capturedCtx;
});
});
});
- it("should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should capture exceptions from XMLHttpRequest event handlers (e.g. onreadystatechange)', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
var xhr = new XMLHttpRequest();
- xhr.open("GET", "/base/subjects/example.json");
+ xhr.open('GET', '/base/subjects/example.json');
// intentionally assign event handlers *after* open, since this is what jQuery does
xhr.onreadystatechange = function wat() {
window.finalizeManualTest();
// replace onreadystatechange with no-op so exception doesn't
// fire more than once as XHR changes loading state
- xhr.onreadystatechange = function() {};
+ xhr.onreadystatechange = function () {};
foo();
};
xhr.send();
- }).then(function(summary) {
+ }).then(function (summary) {
assert.match(summary.events[0].exception.values[0].value, /baz/);
if (IS_LOADER) {
assert.ok(summary.events[0].exception.values[0].mechanism);
} else {
- var handler =
- summary.events[0].exception.values[0].mechanism.data.handler;
+ var handler = summary.events[0].exception.values[0].mechanism.data.handler;
delete summary.events[0].exception.values[0].mechanism.data.handler;
if (summary.window.canReadFunctionName()) {
- assert.equal(handler, "wat");
+ assert.equal(handler, 'wat');
} else {
- assert.equal(handler, "");
+ assert.equal(handler, '');
}
assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
- type: "instrument",
+ type: 'instrument',
handled: true,
data: {
- function: "onreadystatechange",
+ function: 'onreadystatechange',
},
});
}
});
});
- it("should not call XMLHttpRequest onreadystatechange more than once per state", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should not call XMLHttpRequest onreadystatechange more than once per state', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
window.calls = {};
var xhr = new XMLHttpRequest();
- xhr.open("GET", "/base/subjects/example.json");
+ xhr.open('GET', '/base/subjects/example.json');
xhr.onreadystatechange = function wat() {
- window.calls[xhr.readyState] = window.calls[xhr.readyState]
- ? window.calls[xhr.readyState] + 1
- : 1;
+ window.calls[xhr.readyState] = window.calls[xhr.readyState] ? window.calls[xhr.readyState] + 1 : 1;
if (xhr.readyState === 4) {
window.finalizeManualTest();
}
};
xhr.send();
- }).then(function(summary) {
+ }).then(function (summary) {
for (var state in summary.window.calls) {
assert.equal(summary.window.calls[state], 1);
}
@@ -218,127 +215,108 @@ describe("wrapped built-ins", function() {
});
});
- it(
- optional(
- "should capture built-in's mechanism type as instrument",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, function() {
- setTimeout(function() {
- foo();
- });
- }).then(function(summary) {
- if (IS_LOADER) {
- // The async loader doesn't wrap setTimeout
- // so we don't receive the full mechanism
- assert.ok(summary.events[0].exception.values[0].mechanism);
- } else {
- var fn =
- summary.events[0].exception.values[0].mechanism.data.function;
- delete summary.events[0].exception.values[0].mechanism.data;
-
- if (summary.window.canReadFunctionName()) {
- assert.equal(fn, "setTimeout");
- } else {
- assert.equal(fn, "");
- }
-
- assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
- type: "instrument",
- handled: true,
- });
- }
+ it(optional("should capture built-in's mechanism type as instrument", IS_LOADER), function () {
+ return runInSandbox(sandbox, function () {
+ setTimeout(function () {
+ foo();
});
- }
- );
+ }).then(function (summary) {
+ if (IS_LOADER) {
+ // The async loader doesn't wrap setTimeout
+ // so we don't receive the full mechanism
+ assert.ok(summary.events[0].exception.values[0].mechanism);
+ } else {
+ var fn = summary.events[0].exception.values[0].mechanism.data.function;
+ delete summary.events[0].exception.values[0].mechanism.data;
- it(
- optional(
- "should capture built-in's handlers fn name in mechanism data",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, function() {
- var div = document.createElement("div");
- document.body.appendChild(div);
- div.addEventListener(
- "click",
- function namedFunction() {
- foo();
- },
- false
- );
- var click = new MouseEvent("click");
- div.dispatchEvent(click);
- }).then(function(summary) {
- if (IS_LOADER) {
- // The async loader doesn't wrap addEventListener
- // so we don't receive the full mechanism
- assert.ok(summary.events[0].exception.values[0].mechanism);
+ if (summary.window.canReadFunctionName()) {
+ assert.equal(fn, 'setTimeout');
} else {
- var handler =
- summary.events[0].exception.values[0].mechanism.data.handler;
- delete summary.events[0].exception.values[0].mechanism.data.handler;
- var target =
- summary.events[0].exception.values[0].mechanism.data.target;
- delete summary.events[0].exception.values[0].mechanism.data.target;
+ assert.equal(fn, '');
+ }
- if (summary.window.canReadFunctionName()) {
- assert.equal(handler, "namedFunction");
- } else {
- assert.equal(handler, "");
- }
+ assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
+ type: 'instrument',
+ handled: true,
+ });
+ }
+ });
+ });
- // IE vs. Rest of the world
- assert.oneOf(target, ["Node", "EventTarget"]);
- assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
- type: "instrument",
- handled: true,
- data: {
- function: "addEventListener",
- },
- });
+ it(optional("should capture built-in's handlers fn name in mechanism data", IS_LOADER), function () {
+ return runInSandbox(sandbox, function () {
+ var div = document.createElement('div');
+ document.body.appendChild(div);
+ div.addEventListener(
+ 'click',
+ function namedFunction() {
+ foo();
+ },
+ false
+ );
+ var click = new MouseEvent('click');
+ div.dispatchEvent(click);
+ }).then(function (summary) {
+ if (IS_LOADER) {
+ // The async loader doesn't wrap addEventListener
+ // so we don't receive the full mechanism
+ assert.ok(summary.events[0].exception.values[0].mechanism);
+ } else {
+ var handler = summary.events[0].exception.values[0].mechanism.data.handler;
+ delete summary.events[0].exception.values[0].mechanism.data.handler;
+ var target = summary.events[0].exception.values[0].mechanism.data.target;
+ delete summary.events[0].exception.values[0].mechanism.data.target;
+
+ if (summary.window.canReadFunctionName()) {
+ assert.equal(handler, 'namedFunction');
+ } else {
+ assert.equal(handler, '');
}
- });
- }
- );
+
+ // IE vs. Rest of the world
+ assert.oneOf(target, ['Node', 'EventTarget']);
+ assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
+ type: 'instrument',
+ handled: true,
+ data: {
+ function: 'addEventListener',
+ },
+ });
+ }
+ });
+ });
it(
- optional(
- "should fallback to fn name in mechanism data if one is unavailable",
- IS_LOADER
- ),
- function() {
- return runInSandbox(sandbox, function() {
- var div = document.createElement("div");
+ optional('should fallback to fn name in mechanism data if one is unavailable', IS_LOADER),
+ function () {
+ return runInSandbox(sandbox, function () {
+ var div = document.createElement('div');
document.body.appendChild(div);
div.addEventListener(
- "click",
- function() {
+ 'click',
+ function () {
foo();
},
false
);
- var click = new MouseEvent("click");
+ var click = new MouseEvent('click');
div.dispatchEvent(click);
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_LOADER) {
// The async loader doesn't wrap
assert.ok(summary.events[0].exception.values[0].mechanism);
} else {
- var target =
- summary.events[0].exception.values[0].mechanism.data.target;
+ var target = summary.events[0].exception.values[0].mechanism.data.target;
delete summary.events[0].exception.values[0].mechanism.data.target;
// IE vs. Rest of the world
- assert.oneOf(target, ["Node", "EventTarget"]);
+ assert.oneOf(target, ['Node', 'EventTarget']);
assert.deepEqual(summary.events[0].exception.values[0].mechanism, {
- type: "instrument",
+ type: 'instrument',
handled: true,
data: {
- function: "addEventListener",
- handler: "",
+ function: 'addEventListener',
+ handler: '',
},
});
}
diff --git a/packages/browser/test/integration/suites/config.js b/packages/browser/test/integration/suites/config.js
index f3c903b64a57..2637ea8c13b7 100644
--- a/packages/browser/test/integration/suites/config.js
+++ b/packages/browser/test/integration/suites/config.js
@@ -1,19 +1,19 @@
-describe("config", function() {
- it("should allow to ignore specific errors", function() {
- return runInSandbox(sandbox, function() {
- Sentry.captureException(new Error("foo"));
- Sentry.captureException(new Error("ignoreErrorTest"));
- Sentry.captureException(new Error("bar"));
- }).then(function(summary) {
- assert.equal(summary.events[0].exception.values[0].type, "Error");
- assert.equal(summary.events[0].exception.values[0].value, "foo");
- assert.equal(summary.events[1].exception.values[0].type, "Error");
- assert.equal(summary.events[1].exception.values[0].value, "bar");
+describe('config', function () {
+ it('should allow to ignore specific errors', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.captureException(new Error('foo'));
+ Sentry.captureException(new Error('ignoreErrorTest'));
+ Sentry.captureException(new Error('bar'));
+ }).then(function (summary) {
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
+ assert.equal(summary.events[0].exception.values[0].value, 'foo');
+ assert.equal(summary.events[1].exception.values[0].type, 'Error');
+ assert.equal(summary.events[1].exception.values[0].value, 'bar');
});
});
- it("should allow to ignore specific urls", function() {
- return runInSandbox(sandbox, function() {
+ it('should allow to ignore specific urls', function () {
+ return runInSandbox(sandbox, function () {
/**
* We always filter on the caller, not the cause of the error
*
@@ -23,12 +23,12 @@ describe("config", function() {
*
* foo.js is denied in the `init` call (init.js), thus we filter it
* */
- var urlWithDeniedUrl = new Error("filter");
+ var urlWithDeniedUrl = new Error('filter');
urlWithDeniedUrl.stack =
- "Error: bar\n" +
- " at http://localhost:5000/foo.js:7:19\n" +
- " at bar(http://localhost:5000/bar.js:2:3)\n" +
- " at baz(http://localhost:5000/baz.js:2:9)\n";
+ 'Error: bar\n' +
+ ' at http://localhost:5000/foo.js:7:19\n' +
+ ' at bar(http://localhost:5000/bar.js:2:3)\n' +
+ ' at baz(http://localhost:5000/baz.js:2:9)\n';
/**
* > foo-pass.js file called a function in bar-pass.js
@@ -37,19 +37,19 @@ describe("config", function() {
*
* foo-pass.js is *not* denied in the `init` call (init.js), thus we don't filter it
* */
- var urlWithoutDeniedUrl = new Error("pass");
+ var urlWithoutDeniedUrl = new Error('pass');
urlWithoutDeniedUrl.stack =
- "Error: bar\n" +
- " at http://localhost:5000/foo-pass.js:7:19\n" +
- " at bar(http://localhost:5000/bar-pass.js:2:3)\n" +
- " at baz(http://localhost:5000/baz-pass.js:2:9)\n";
+ 'Error: bar\n' +
+ ' at http://localhost:5000/foo-pass.js:7:19\n' +
+ ' at bar(http://localhost:5000/bar-pass.js:2:3)\n' +
+ ' at baz(http://localhost:5000/baz-pass.js:2:9)\n';
Sentry.captureException(urlWithDeniedUrl);
Sentry.captureException(urlWithoutDeniedUrl);
- }).then(function(summary) {
+ }).then(function (summary) {
assert.lengthOf(summary.events, 1);
- assert.equal(summary.events[0].exception.values[0].type, "Error");
- assert.equal(summary.events[0].exception.values[0].value, "pass");
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
+ assert.equal(summary.events[0].exception.values[0].value, 'pass');
});
});
});
diff --git a/packages/browser/test/integration/suites/helpers.js b/packages/browser/test/integration/suites/helpers.js
index 7990ca64f85b..a4104df81750 100644
--- a/packages/browser/test/integration/suites/helpers.js
+++ b/packages/browser/test/integration/suites/helpers.js
@@ -2,15 +2,11 @@ function evaluateInSandbox(sandbox, code) {
// use setTimeout so stack trace doesn't go all the way back to mocha test runner
sandbox &&
sandbox.contentWindow &&
- sandbox.contentWindow.eval(
- "window.originalBuiltIns.setTimeout.call(window, " +
- code.toString() +
- ");"
- );
+ sandbox.contentWindow.eval('window.originalBuiltIns.setTimeout.call(window, ' + code.toString() + ');');
}
function runInSandbox(sandbox, options, code) {
- if (typeof options === "function") {
+ if (typeof options === 'function') {
// eslint-disable-next-line no-param-reassign
code = options;
// eslint-disable-next-line no-param-reassign
@@ -18,18 +14,18 @@ function runInSandbox(sandbox, options, code) {
}
var resolveTest;
- var donePromise = new Promise(function(resolve) {
+ var donePromise = new Promise(function (resolve) {
resolveTest = resolve;
});
- sandbox.contentWindow.resolveTest = function(summary) {
+ sandbox.contentWindow.resolveTest = function (summary) {
clearTimeout(lastResort);
resolveTest(summary);
};
// If by some unexplainable way we reach the timeout limit, try to finalize the test and pray for the best
// NOTE: 5000 so it's easier to grep for all timeout instances (shell.js, loader-specific.js and here)
- var lastResort = setTimeout(function() {
- var force = function() {
+ var lastResort = setTimeout(function () {
+ var force = function () {
window.resolveTest({
events: events,
breadcrumbs: breadcrumbs,
@@ -41,7 +37,7 @@ function runInSandbox(sandbox, options, code) {
}
}, 5000 - 500);
- var finalize = function() {
+ var finalize = function () {
var summary = {
events: events,
eventHints: eventHints,
@@ -50,20 +46,20 @@ function runInSandbox(sandbox, options, code) {
window: window,
};
- Sentry.onLoad(function() {
- setTimeout(function() {
+ Sentry.onLoad(function () {
+ setTimeout(function () {
Sentry.flush()
- .then(function() {
+ .then(function () {
window.resolveTest(summary);
})
- .catch(function() {
+ .catch(function () {
window.resolveTest(summary);
});
});
});
};
- sandbox.contentWindow.finalizeManualTest = function() {
+ sandbox.contentWindow.finalizeManualTest = function () {
evaluateInSandbox(sandbox, finalize.toString());
};
@@ -77,10 +73,10 @@ function runInSandbox(sandbox, options, code) {
}
function createSandbox(done, file) {
- var sandbox = document.createElement("iframe");
- sandbox.style.display = "none";
- sandbox.src = "/base/variants/" + file + ".html";
- sandbox.onload = function() {
+ var sandbox = document.createElement('iframe');
+ sandbox.style.display = 'none';
+ sandbox.src = '/base/variants/' + file + '.html';
+ sandbox.onload = function () {
done();
};
document.body.appendChild(sandbox);
@@ -88,5 +84,5 @@ function createSandbox(done, file) {
}
function optional(title, condition) {
- return condition ? "⚠ SKIPPED: " + title : title;
+ return condition ? '⚠ SKIPPED: ' + title : title;
}
diff --git a/packages/browser/test/integration/suites/loader-specific.js b/packages/browser/test/integration/suites/loader-specific.js
index 145fcd6e1dff..6ebfd3fb84ab 100644
--- a/packages/browser/test/integration/suites/loader-specific.js
+++ b/packages/browser/test/integration/suites/loader-specific.js
@@ -1,43 +1,40 @@
-var loaderVariants = [
- "loader-with-no-global-init",
- "loader-with-no-global-init-lazy-no",
-];
+var loaderVariants = ['loader-with-no-global-init', 'loader-with-no-global-init-lazy-no'];
for (var idx in loaderVariants) {
- (function() {
- describe(loaderVariants[idx], function() {
+ (function () {
+ describe(loaderVariants[idx], function () {
this.timeout(60000);
this.retries(3);
var sandbox;
- beforeEach(function(done) {
+ beforeEach(function (done) {
sandbox = createSandbox(done, loaderVariants[idx]);
});
- afterEach(function() {
+ afterEach(function () {
document.body.removeChild(sandbox);
});
- describe("Loader Specific Tests - With no Global init() call", function() {
- it("should add breadcrumb from onLoad callback from undefined error", function() {
- return runInSandbox(sandbox, function() {
- Sentry.onLoad(function() {
+ describe('Loader Specific Tests - With no Global init() call', function () {
+ it('should add breadcrumb from onLoad callback from undefined error', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.onLoad(function () {
initSDK();
Sentry.addBreadcrumb({
- category: "auth",
- message: "testing loader",
- level: "error",
+ category: 'auth',
+ message: 'testing loader',
+ level: 'error',
});
});
- setTimeout(function() {
- Sentry.captureMessage("test");
+ setTimeout(function () {
+ Sentry.captureMessage('test');
});
undefinedMethod();
- }).then(function(summary) {
+ }).then(function (summary) {
assert.ok(summary.breadcrumbs);
assert.lengthOf(summary.breadcrumbs, 1);
- assert.equal(summary.breadcrumbs[0].message, "testing loader");
+ assert.equal(summary.breadcrumbs[0].message, 'testing loader');
});
});
});
diff --git a/packages/browser/test/integration/suites/loader.js b/packages/browser/test/integration/suites/loader.js
index 3099417ae3de..9315576bac86 100644
--- a/packages/browser/test/integration/suites/loader.js
+++ b/packages/browser/test/integration/suites/loader.js
@@ -1,29 +1,26 @@
if (IS_LOADER) {
- describe("Loader Specific Tests", function() {
- it("should add breadcrumb from onLoad callback from undefined error", function() {
- return runInSandbox(sandbox, function() {
- Sentry.onLoad(function() {
+ describe('Loader Specific Tests', function () {
+ it('should add breadcrumb from onLoad callback from undefined error', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.onLoad(function () {
Sentry.addBreadcrumb({
- category: "auth",
- message: "testing loader",
- level: "error",
+ category: 'auth',
+ message: 'testing loader',
+ level: 'error',
});
});
- setTimeout(function() {
- Sentry.captureMessage("test");
+ setTimeout(function () {
+ Sentry.captureMessage('test');
});
undefinedMethod();
- }).then(function(summary) {
+ }).then(function (summary) {
if (IS_ASYNC_LOADER) {
assert.notOk(summary.events[0].breadcrumbs);
} else {
if (summary.events[0].breadcrumbs) {
assert.ok(summary.events[0].breadcrumbs);
assert.lengthOf(summary.events[0].breadcrumbs, 1);
- assert.equal(
- summary.events[0].breadcrumbs[0].message,
- "testing loader"
- );
+ assert.equal(summary.events[0].breadcrumbs[0].message, 'testing loader');
} else {
// This seems to be happening only in chrome
assert.notOk(summary.events[0].breadcrumbs);
@@ -32,27 +29,24 @@ if (IS_LOADER) {
});
});
- it("should add breadcrumb from onLoad callback from undefined error with custom init()", function() {
- return runInSandbox(sandbox, function() {
- Sentry.onLoad(function() {
+ it('should add breadcrumb from onLoad callback from undefined error with custom init()', function () {
+ return runInSandbox(sandbox, function () {
+ Sentry.onLoad(function () {
Sentry.init({ debug: true });
Sentry.addBreadcrumb({
- category: "auth",
- message: "testing loader",
- level: "error",
+ category: 'auth',
+ message: 'testing loader',
+ level: 'error',
});
});
- setTimeout(function() {
- Sentry.captureMessage("test");
+ setTimeout(function () {
+ Sentry.captureMessage('test');
});
undefinedMethod(); // trigger error
- }).then(function(summary) {
+ }).then(function (summary) {
assert.ok(summary.events[0].breadcrumbs);
assert.lengthOf(summary.events[0].breadcrumbs, 1);
- assert.equal(
- summary.events[0].breadcrumbs[0].message,
- "testing loader"
- );
+ assert.equal(summary.events[0].breadcrumbs[0].message, 'testing loader');
});
});
});
diff --git a/packages/browser/test/integration/suites/onerror.js b/packages/browser/test/integration/suites/onerror.js
index b32a5e4c67f1..d5a7f155d723 100644
--- a/packages/browser/test/integration/suites/onerror.js
+++ b/packages/browser/test/integration/suites/onerror.js
@@ -1,38 +1,32 @@
-describe("window.onerror", function() {
- it("should catch syntax errors", function() {
- return runInSandbox(sandbox, function() {
- eval("foo{};");
- }).then(function(summary) {
+describe('window.onerror', function () {
+ it('should catch syntax errors', function () {
+ return runInSandbox(sandbox, function () {
+ eval('foo{};');
+ }).then(function (summary) {
// ¯\_(ツ)_/¯
if (summary.window.isBelowIE11()) {
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
} else {
assert.match(summary.events[0].exception.values[0].type, /SyntaxError/);
}
- assert.equal(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- ); // just one frame
+ assert.equal(summary.events[0].exception.values[0].stacktrace.frames.length, 1); // just one frame
});
});
- it("should catch thrown strings", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should catch thrown strings', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
// intentionally loading this error via a script file to make
// sure it is 1) not caught by instrumentation 2) doesn't trigger
// "Script error"
- var script = document.createElement("script");
- script.src = "/base/subjects/throw-string.js";
- script.onload = function() {
+ var script = document.createElement('script');
+ script.src = '/base/subjects/throw-string.js';
+ script.onload = function () {
window.finalizeManualTest();
};
document.head.appendChild(script);
- }).then(function(summary) {
+ }).then(function (summary) {
assert.match(summary.events[0].exception.values[0].value, /stringError$/);
- assert.equal(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- ); // always 1 because thrown strings can't provide > 1 frame
+ assert.equal(summary.events[0].exception.values[0].stacktrace.frames.length, 1); // always 1 because thrown strings can't provide > 1 frame
// some browsers extract proper url, line, and column for thrown strings
// but not all - falls back to frame url
@@ -41,42 +35,36 @@ describe("window.onerror", function() {
/(\/subjects\/throw-string.js|\/base\/variants\/)/
);
assert.match(
- summary.events[0].exception.values[0].stacktrace.frames[0]["function"],
+ summary.events[0].exception.values[0].stacktrace.frames[0]['function'],
/throwStringError|\?|global code/i
);
});
});
- it("should catch thrown objects", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should catch thrown objects', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
// intentionally loading this error via a script file to make
// sure it is 1) not caught by instrumentation 2) doesn't trigger
// "Script error"
- var script = document.createElement("script");
- script.src = "/base/subjects/throw-object.js";
- script.onload = function() {
+ var script = document.createElement('script');
+ script.src = '/base/subjects/throw-object.js';
+ script.onload = function () {
window.finalizeManualTest();
};
document.head.appendChild(script);
- }).then(function(summary) {
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ }).then(function (summary) {
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
// ¯\_(ツ)_/¯
if (summary.window.isBelowIE11()) {
- assert.equal(
- summary.events[0].exception.values[0].value,
- "[object Object]"
- );
+ assert.equal(summary.events[0].exception.values[0].value, '[object Object]');
} else {
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error exception captured with keys: error, somekey"
+ 'Non-Error exception captured with keys: error, somekey'
);
}
- assert.equal(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- ); // always 1 because thrown objects can't provide > 1 frame
+ assert.equal(summary.events[0].exception.values[0].stacktrace.frames.length, 1); // always 1 because thrown objects can't provide > 1 frame
// some browsers extract proper url, line, and column for thrown objects
// but not all - falls back to frame url
@@ -85,79 +73,70 @@ describe("window.onerror", function() {
/(\/subjects\/throw-object.js|\/base\/variants\/)/
);
assert.match(
- summary.events[0].exception.values[0].stacktrace.frames[0]["function"],
+ summary.events[0].exception.values[0].stacktrace.frames[0]['function'],
/throwStringError|\?|global code/i
);
});
});
- it("should catch thrown errors", function() {
- return runInSandbox(sandbox, { manual: true }, function() {
+ it('should catch thrown errors', function () {
+ return runInSandbox(sandbox, { manual: true }, function () {
// intentionally loading this error via a script file to make
// sure it is 1) not caught by instrumentation 2) doesn't trigger
// "Script error"
- var script = document.createElement("script");
- script.src = "/base/subjects/throw-error.js";
- script.onload = function() {
+ var script = document.createElement('script');
+ script.src = '/base/subjects/throw-error.js';
+ script.onload = function () {
window.finalizeManualTest();
};
document.head.appendChild(script);
- }).then(function(summary) {
+ }).then(function (summary) {
// ¯\_(ツ)_/¯
if (summary.window.isBelowIE11()) {
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
} else {
assert.match(summary.events[0].exception.values[0].type, /^Error/);
}
assert.match(summary.events[0].exception.values[0].value, /realError$/);
// 1 or 2 depending on platform
- assert.isAtLeast(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- );
- assert.isAtMost(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 2
- );
- assert.match(
- summary.events[0].exception.values[0].stacktrace.frames[0].filename,
- /\/subjects\/throw-error\.js/
- );
+ assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1);
+ assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 2);
+ assert.match(summary.events[0].exception.values[0].stacktrace.frames[0].filename, /\/subjects\/throw-error\.js/);
assert.match(
- summary.events[0].exception.values[0].stacktrace.frames[0]["function"],
+ summary.events[0].exception.values[0].stacktrace.frames[0]['function'],
/\?|global code|throwRealError/i
);
});
});
- it("should onerror calls with non-string first argument gracefully", function() {
- return runInSandbox(sandbox, function() {
+ it('should onerror calls with non-string first argument gracefully', function () {
+ return runInSandbox(sandbox, function () {
window.onerror({
- type: "error",
- otherKey: "hi",
+ type: 'error',
+ otherKey: 'hi',
});
- }).then(function(summary) {
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ }).then(function (summary) {
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error exception captured with keys: otherKey, type"
+ 'Non-Error exception captured with keys: otherKey, type'
);
assert.deepEqual(summary.events[0].extra.__serialized__, {
- type: "error",
- otherKey: "hi",
+ type: 'error',
+ otherKey: 'hi',
});
});
});
- it("should NOT catch an exception already caught [but rethrown] via Sentry.captureException", function() {
- return runInSandbox(sandbox, function() {
+ it('should NOT catch an exception already caught [but rethrown] via Sentry.captureException', function () {
+ return runInSandbox(sandbox, function () {
try {
foo();
} catch (e) {
Sentry.captureException(e);
throw e; // intentionally re-throw
}
- }).then(function(summary) {
+ }).then(function (summary) {
// IE10 uses different type (Error instead of ReferenceError) for rethrown errors...
if (!summary.window.isBelowIE11()) {
assert.equal(summary.events.length, 1);
diff --git a/packages/browser/test/integration/suites/onunhandledrejection.js b/packages/browser/test/integration/suites/onunhandledrejection.js
index 1bb86b44d634..d32708eb88cd 100644
--- a/packages/browser/test/integration/suites/onunhandledrejection.js
+++ b/packages/browser/test/integration/suites/onunhandledrejection.js
@@ -1,31 +1,22 @@
-describe("window.onunhandledrejection", function() {
- it("should capture unhandledrejection with error", function() {
- return runInSandbox(sandbox, function() {
+describe('window.onunhandledrejection', function () {
+ it('should capture unhandledrejection with error', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
- Promise.reject(new Error("test2"));
+ Promise.reject(new Error('test2'));
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
- assert.equal(summary.events[0].exception.values[0].value, "test2");
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ assert.equal(summary.events[0].exception.values[0].value, 'test2');
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
// Of course Safari had to screw up here...
if (!/Version\/\d.+Safari\/\d/.test(window.navigator.userAgent)) {
- assert.isAtLeast(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- );
+ assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1);
}
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
- );
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
@@ -35,45 +26,36 @@ describe("window.onunhandledrejection", function() {
// the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec
// see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and
// https://github.com/getsentry/sentry-javascript/issues/2380
- it("should capture PromiseRejectionEvent cast to CustomEvent with type unhandledrejection", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture PromiseRejectionEvent cast to CustomEvent with type unhandledrejection', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
// this isn't how it happens in real life, in that the promise and reason
// values come from an actual PromiseRejectionEvent, but it's enough to test
// how the SDK handles the structure
window.dispatchEvent(
- new CustomEvent("unhandledrejection", {
+ new CustomEvent('unhandledrejection', {
detail: {
- promise: new Promise(function() {}),
+ promise: new Promise(function () {}),
// we're testing with an error here but it could be anything - really
// all we're testing is that it gets dug out correctly
- reason: new Error("test2"),
+ reason: new Error('test2'),
},
})
);
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
- assert.equal(summary.events[0].exception.values[0].value, "test2");
- assert.equal(summary.events[0].exception.values[0].type, "Error");
+ assert.equal(summary.events[0].exception.values[0].value, 'test2');
+ assert.equal(summary.events[0].exception.values[0].type, 'Error');
// Of course Safari had to screw up here...
if (!/Version\/\d.+Safari\/\d/.test(window.navigator.userAgent)) {
- assert.isAtLeast(
- summary.events[0].exception.values[0].stacktrace.frames.length,
- 1
- );
+ assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1);
}
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
- );
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
// even though it's a regular Event (rather than a PRE) it should still only
// come through this channel
assert.equal(summary.events.length, 1);
@@ -83,29 +65,23 @@ describe("window.onunhandledrejection", function() {
// there's no evidence that this actually happens, but it could, and our code correctly
// handles it, so might as well prevent future regression on that score
- it("should capture a random Event with type unhandledrejection", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture a random Event with type unhandledrejection', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
- window.dispatchEvent(new Event("unhandledrejection"));
+ window.dispatchEvent(new Event('unhandledrejection'));
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type"
- );
- assert.equal(summary.events[0].exception.values[0].type, "Event");
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'Event');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
// even though it's a regular Event (rather than a PRE) it should sill only
// come through this channel
assert.equal(summary.events.length, 1);
@@ -113,104 +89,77 @@ describe("window.onunhandledrejection", function() {
});
});
- it("should capture unhandledrejection with a string", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with a string', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
- Promise.reject("test");
+ Promise.reject('test');
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with value: test"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with value: test'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with a monster string", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with a monster string', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
- Promise.reject("test".repeat(100));
+ Promise.reject('test'.repeat(100));
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(summary.events[0].exception.values[0].value.length, 253);
assert.include(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with value: "
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with value: '
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with an object", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with an object', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
- Promise.reject({ a: "b", b: "c", c: "d" });
+ Promise.reject({ a: 'b', b: 'c', c: 'd' });
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with keys: a, b, c"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with keys: a, b, c'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with an monster object", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with an monster object', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
var a = {
- a: "1".repeat("100"),
- b: "2".repeat("100"),
- c: "3".repeat("100"),
+ a: '1'.repeat('100'),
+ b: '2'.repeat('100'),
+ c: '3'.repeat('100'),
};
a.d = a.a;
a.e = a;
@@ -218,121 +167,85 @@ describe("window.onunhandledrejection", function() {
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with keys: a, b, c, d, e"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with keys: a, b, c, d, e'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with a number", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with a number', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
Promise.reject(1337);
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with value: 1337"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with value: 1337'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with null", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with null', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
Promise.reject(null);
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with value: null"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with value: null'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should capture unhandledrejection with an undefined", function() {
- return runInSandbox(sandbox, function() {
+ it('should capture unhandledrejection with an undefined', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
Promise.reject(undefined);
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
// non-error rejections don't provide stacktraces so we can skip that assertion
assert.equal(
summary.events[0].exception.values[0].value,
- "Non-Error promise rejection captured with value: undefined"
- );
- assert.equal(
- summary.events[0].exception.values[0].type,
- "UnhandledRejection"
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.handled,
- false
- );
- assert.equal(
- summary.events[0].exception.values[0].mechanism.type,
- "onunhandledrejection"
+ 'Non-Error promise rejection captured with value: undefined'
);
+ assert.equal(summary.events[0].exception.values[0].type, 'UnhandledRejection');
+ assert.equal(summary.events[0].exception.values[0].mechanism.handled, false);
+ assert.equal(summary.events[0].exception.values[0].mechanism.type, 'onunhandledrejection');
}
});
});
- it("should skip our own failed requests that somehow bubbled-up to unhandledrejection handler", function() {
- return runInSandbox(sandbox, function() {
+ it('should skip our own failed requests that somehow bubbled-up to unhandledrejection handler', function () {
+ return runInSandbox(sandbox, function () {
if (supportsOnunhandledRejection()) {
Promise.reject({
__sentry_own_request__: true,
@@ -344,7 +257,7 @@ describe("window.onunhandledrejection", function() {
} else {
window.resolveTest({ window: window });
}
- }).then(function(summary) {
+ }).then(function (summary) {
if (summary.window.supportsOnunhandledRejection()) {
assert.equal(summary.events.length, 2);
}
diff --git a/packages/browser/test/integration/suites/shell.js b/packages/browser/test/integration/suites/shell.js
index 089aaca8848f..0b594f3d2eff 100644
--- a/packages/browser/test/integration/suites/shell.js
+++ b/packages/browser/test/integration/suites/shell.js
@@ -1,21 +1,21 @@
-var variants = ["frame", "loader", "loader-lazy-no"];
+var variants = ['frame', 'loader', 'loader-lazy-no'];
function runVariant(variant) {
var IS_LOADER = !!variant.match(/^loader/);
var IS_ASYNC_LOADER = !!variant.match(/^loader$/);
var IS_SYNC_LOADER = !!variant.match(/^loader-lazy-no$/);
- describe(variant, function() {
+ describe(variant, function () {
this.timeout(60000);
this.retries(3);
var sandbox;
- beforeEach(function(done) {
+ beforeEach(function (done) {
sandbox = createSandbox(done, variant);
});
- afterEach(function() {
+ afterEach(function () {
document.body.removeChild(sandbox);
});
@@ -33,7 +33,7 @@ function runVariant(variant) {
}
for (var idx in variants) {
- (function() {
+ (function () {
runVariant(variants[idx]);
})();
}
diff --git a/packages/browser/test/package/npm-build.js b/packages/browser/test/package/npm-build.js
index ded02ea63a86..c74fb5ba9831 100644
--- a/packages/browser/test/package/npm-build.js
+++ b/packages/browser/test/package/npm-build.js
@@ -1,69 +1,69 @@
-/* eslint-disable no-console */
-const fs = require('fs');
-const path = require('path');
-
-const webpack = require('webpack');
-const { JSDOM } = require('jsdom');
-
-webpack(
- {
- entry: path.join(__dirname, 'test-code.js'),
- output: {
- path: __dirname,
- filename: 'tmp.js',
- },
- mode: 'development',
- },
- (err, stats) => {
- if (err) {
- console.error(err.stack || err);
- if (err.details) {
- console.error(err.details);
- }
- return;
- }
-
- const info = stats.toJson();
-
- if (stats.hasErrors()) {
- console.error(info.errors);
- process.exit(1);
- }
-
- if (stats.hasWarnings()) {
- console.warn(info.warnings);
- process.exit(1);
- }
-
- runTests();
- },
-);
-
-function runTests() {
- const bundlePath = path.join(__dirname, 'tmp.js');
- const { window } = new JSDOM('', { runScripts: 'dangerously' });
-
- window.onerror = function () {
- console.error('ERROR thrown in manual test:');
- console.error(arguments);
- console.error('------------------');
- process.exit(1);
- };
-
- const myLibrary = fs.readFileSync(bundlePath, { encoding: 'utf-8' });
-
- if (myLibrary.indexOf('tslib_1__default') !== -1) {
- console.log('"tslib_1__default" reappeared...');
- process.exit(1);
- }
-
- const scriptEl = window.document.createElement('script');
- scriptEl.textContent = myLibrary;
- window.document.body.appendChild(scriptEl);
-
- // Testing https://github.com/getsentry/sentry-javascript/issues/2043
- const scriptEl2 = window.document.createElement('script');
- scriptEl2.textContent = myLibrary;
- window.document.body.appendChild(scriptEl2);
- // ------------------------------------------------------------------
-}
+/* eslint-disable no-console */
+const fs = require('fs');
+const path = require('path');
+
+const webpack = require('webpack');
+const { JSDOM } = require('jsdom');
+
+webpack(
+ {
+ entry: path.join(__dirname, 'test-code.js'),
+ output: {
+ path: __dirname,
+ filename: 'tmp.js',
+ },
+ mode: 'development',
+ },
+ (err, stats) => {
+ if (err) {
+ console.error(err.stack || err);
+ if (err.details) {
+ console.error(err.details);
+ }
+ return;
+ }
+
+ const info = stats.toJson();
+
+ if (stats.hasErrors()) {
+ console.error(info.errors);
+ process.exit(1);
+ }
+
+ if (stats.hasWarnings()) {
+ console.warn(info.warnings);
+ process.exit(1);
+ }
+
+ runTests();
+ },
+);
+
+function runTests() {
+ const bundlePath = path.join(__dirname, 'tmp.js');
+ const { window } = new JSDOM('', { runScripts: 'dangerously' });
+
+ window.onerror = function () {
+ console.error('ERROR thrown in manual test:');
+ console.error(arguments);
+ console.error('------------------');
+ process.exit(1);
+ };
+
+ const myLibrary = fs.readFileSync(bundlePath, { encoding: 'utf-8' });
+
+ if (myLibrary.indexOf('tslib_1__default') !== -1) {
+ console.log('"tslib_1__default" reappeared...');
+ process.exit(1);
+ }
+
+ const scriptEl = window.document.createElement('script');
+ scriptEl.textContent = myLibrary;
+ window.document.body.appendChild(scriptEl);
+
+ // Testing https://github.com/getsentry/sentry-javascript/issues/2043
+ const scriptEl2 = window.document.createElement('script');
+ scriptEl2.textContent = myLibrary;
+ window.document.body.appendChild(scriptEl2);
+ // ------------------------------------------------------------------
+}
diff --git a/packages/ember/.template-lintrc.js b/packages/ember/.template-lintrc.js
index f38737001038..3b0b9af953bb 100644
--- a/packages/ember/.template-lintrc.js
+++ b/packages/ember/.template-lintrc.js
@@ -1,5 +1,5 @@
'use strict';
module.exports = {
- extends: 'octane'
+ extends: 'octane',
};
diff --git a/packages/ember/addon/index.ts b/packages/ember/addon/index.ts
index 341af580e960..da359e705dd4 100644
--- a/packages/ember/addon/index.ts
+++ b/packages/ember/addon/index.ts
@@ -51,7 +51,7 @@ export function InitSentryForEmber(_runtimeConfig?: BrowserOptions) {
if (environmentConfig.ignoreEmberOnErrorWarning) {
return;
}
- next(null, function() {
+ next(null, function () {
warn(
'Ember.onerror found. Using Ember.onerror can hide some errors (such as flushed runloop errors) from Sentry. Use Sentry.captureException to capture errors within Ember.onError or remove it to have errors caught by Sentry directly. This error can be silenced via addon configuration.',
!Ember.onerror,
@@ -64,9 +64,7 @@ export function InitSentryForEmber(_runtimeConfig?: BrowserOptions) {
}
export const getActiveTransaction = () => {
- return Sentry.getCurrentHub()
- ?.getScope()
- ?.getTransaction();
+ return Sentry.getCurrentHub()?.getScope()?.getTransaction();
};
export const instrumentRoutePerformance = (BaseRoute: any) => {
diff --git a/packages/ember/addon/instance-initializers/sentry-performance.ts b/packages/ember/addon/instance-initializers/sentry-performance.ts
index e6ddf066f21c..5bb3024f7df6 100644
--- a/packages/ember/addon/instance-initializers/sentry-performance.ts
+++ b/packages/ember/addon/instance-initializers/sentry-performance.ts
@@ -2,7 +2,7 @@ import ApplicationInstance from '@ember/application/instance';
import Ember from 'ember';
import { run, _backburner, scheduleOnce } from '@ember/runloop';
import * as Sentry from '@sentry/browser';
-import { ExtendedBackburner } from "@sentry/ember/runloop";
+import { ExtendedBackburner } from '@sentry/ember/runloop';
import { Span, Transaction, Integration } from '@sentry/types';
import { EmberRunQueues } from '@ember/runloop/-private/types';
import { getActiveTransaction } from '..';
@@ -34,7 +34,7 @@ export function initialize(appInstance: ApplicationInstance): void {
}
}
-function getBackburner(): Pick {
+function getBackburner(): Pick {
if (_backburner) {
return _backburner;
}
@@ -45,8 +45,8 @@ function getBackburner(): Pick {
return {
on() {},
- off() {}
- }
+ off() {},
+ };
}
function getTransitionInformation(transition: any, router: any) {
diff --git a/packages/ember/config/ember-try.js b/packages/ember/config/ember-try.js
index f6de0683c64c..451824206cd3 100644
--- a/packages/ember/config/ember-try.js
+++ b/packages/ember/config/ember-try.js
@@ -9,7 +9,7 @@ const { embroiderSafe } = require('@embroider/test-setup');
*
* @returns The versions which should be tested, along with their respective config
*/
-module.exports = async function() {
+module.exports = async function () {
// whenever and wherever we test, we want to at least test against the latest version of ember
let scenarios = [
{
diff --git a/packages/ember/config/environment.js b/packages/ember/config/environment.js
index 0dfaed4728b3..331ab30dfe21 100644
--- a/packages/ember/config/environment.js
+++ b/packages/ember/config/environment.js
@@ -1,5 +1,5 @@
'use strict';
-module.exports = function(/* environment, appConfig */) {
- return { };
+module.exports = function (/* environment, appConfig */) {
+ return {};
};
diff --git a/packages/ember/ember-cli-build.js b/packages/ember/ember-cli-build.js
index 859d741276cb..242591820521 100644
--- a/packages/ember/ember-cli-build.js
+++ b/packages/ember/ember-cli-build.js
@@ -2,7 +2,7 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
-module.exports = function(defaults) {
+module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
// Add options here
});
diff --git a/packages/ember/testem.js b/packages/ember/testem.js
index 49f53feed6c1..ed2f37124ad4 100644
--- a/packages/ember/testem.js
+++ b/packages/ember/testem.js
@@ -3,12 +3,8 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
- launch_in_ci: [
- 'Chrome'
- ],
- launch_in_dev: [
- 'Chrome'
- ],
+ launch_in_ci: ['Chrome'],
+ launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
browser_args: {
Chrome: {
@@ -20,8 +16,8 @@ module.exports = {
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
- '--window-size=1440,900'
- ].filter(Boolean)
- }
- }
+ '--window-size=1440,900',
+ ].filter(Boolean),
+ },
+ },
};
diff --git a/packages/ember/tests/acceptance/sentry-errors-test.js b/packages/ember/tests/acceptance/sentry-errors-test.js
index 19909b1f7b27..c1401ef62b33 100644
--- a/packages/ember/tests/acceptance/sentry-errors-test.js
+++ b/packages/ember/tests/acceptance/sentry-errors-test.js
@@ -34,11 +34,11 @@ function assertSentryCall(assert, callNumber, options) {
});
}
-module('Acceptance | Sentry Errors', function(hooks) {
+module('Acceptance | Sentry Errors', function (hooks) {
setupApplicationTest(hooks);
setupSentryTest(hooks);
- test('Check "Throw Generic Javascript Error"', async function(assert) {
+ test('Check "Throw Generic Javascript Error"', async function (assert) {
await visit('/');
const button = find('[data-test-button="Throw Generic Javascript Error"]');
@@ -48,7 +48,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
assertSentryCall(assert, 0, { errorBodyContains: [...this.errorMessages] });
});
- test('Check "Throw EmberError"', async function(assert) {
+ test('Check "Throw EmberError"', async function (assert) {
await visit('/');
const button = find('[data-test-button="Throw EmberError"]');
@@ -58,7 +58,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
assertSentryCall(assert, 0, { errorBodyContains: [...this.errorMessages] });
});
- test('Check "Caught Thrown EmberError"', async function(assert) {
+ test('Check "Caught Thrown EmberError"', async function (assert) {
await visit('/');
const button = find('[data-test-button="Caught Thrown EmberError"]');
@@ -67,7 +67,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
assertSentryErrorCount(assert, 0);
});
- test('Check "Error From Fetch"', async function(assert) {
+ test('Check "Error From Fetch"', async function (assert) {
this.fetchStub.onFirstCall().callsFake((...args) => {
return this.fetchStub.callsThrough(args);
});
@@ -85,7 +85,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
});
});
- test('Check "Error in AfterRender"', async function(assert) {
+ test('Check "Error in AfterRender"', async function (assert) {
await visit('/');
const button = find('[data-test-button="Error in AfterRender"]');
@@ -96,7 +96,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
assertSentryCall(assert, 0, { errorBodyContains: [...this.errorMessages] });
});
- test('Check "RSVP Rejection"', async function(assert) {
+ test('Check "RSVP Rejection"', async function (assert) {
await visit('/');
const button = find('[data-test-button="RSVP Rejection"]');
@@ -107,7 +107,7 @@ module('Acceptance | Sentry Errors', function(hooks) {
assertSentryCall(assert, 0, { errorBodyContains: [this.qunitOnUnhandledRejection.getCall(0).args[0]] });
});
- test('Check "Error inside RSVP"', async function(assert) {
+ test('Check "Error inside RSVP"', async function (assert) {
await visit('/');
const button = find('[data-test-button="Error inside RSVP"]');
diff --git a/packages/ember/tests/acceptance/sentry-performance-test.js b/packages/ember/tests/acceptance/sentry-performance-test.js
index 63543cb43af1..35ac024b4af3 100644
--- a/packages/ember/tests/acceptance/sentry-performance-test.js
+++ b/packages/ember/tests/acceptance/sentry-performance-test.js
@@ -50,11 +50,11 @@ function assertSentryCall(assert, callNumber, options) {
}
}
-module('Acceptance | Sentry Transactions', function(hooks) {
+module('Acceptance | Sentry Transactions', function (hooks) {
setupApplicationTest(hooks);
setupSentryTest(hooks);
- test('Test transaction', async function(assert) {
+ test('Test transaction', async function (assert) {
await visit('/tracing');
assertSentryTransactionCount(assert, 1);
@@ -78,7 +78,7 @@ module('Acceptance | Sentry Transactions', function(hooks) {
});
});
- test('Test navigating to slow route', async function(assert) {
+ test('Test navigating to slow route', async function (assert) {
await visit('/tracing');
const button = find('[data-test-button="Transition to slow loading route"]');
diff --git a/packages/ember/tests/dummy/app/components/slow-loading-list.ts b/packages/ember/tests/dummy/app/components/slow-loading-list.ts
index 8df604bb92ff..9ef19af6da88 100644
--- a/packages/ember/tests/dummy/app/components/slow-loading-list.ts
+++ b/packages/ember/tests/dummy/app/components/slow-loading-list.ts
@@ -2,10 +2,10 @@ import Component from '@ember/component';
import { computed } from '@ember/object';
export default Component.extend({
- _title: computed('title', function() {
+ _title: computed('title', function () {
return this.title || 'Slow Loading List';
}),
- rowItems: computed('items', function() {
+ rowItems: computed('items', function () {
return new Array(parseInt(this.items)).fill(0).map((_, index) => {
return {
index: index + 1,
diff --git a/packages/ember/tests/dummy/app/router.js b/packages/ember/tests/dummy/app/router.js
index eece01fb40ae..5e5dd54a4db2 100644
--- a/packages/ember/tests/dummy/app/router.js
+++ b/packages/ember/tests/dummy/app/router.js
@@ -6,9 +6,9 @@ export default class Router extends EmberRouter {
rootURL = config.rootURL;
}
-Router.map(function() {
+Router.map(function () {
this.route('tracing');
- this.route('slow-loading-route', function() {
+ this.route('slow-loading-route', function () {
this.route('index', { path: '/' });
});
});
diff --git a/packages/ember/tests/dummy/config/environment.js b/packages/ember/tests/dummy/config/environment.js
index 29e7ed892dfe..6f27cd025bf1 100644
--- a/packages/ember/tests/dummy/config/environment.js
+++ b/packages/ember/tests/dummy/config/environment.js
@@ -1,6 +1,6 @@
'use strict';
-module.exports = function(environment) {
+module.exports = function (environment) {
let ENV = {
modulePrefix: 'dummy',
environment,
diff --git a/packages/ember/tests/dummy/config/targets.js b/packages/ember/tests/dummy/config/targets.js
index 276d39d41202..7c76181f14f2 100644
--- a/packages/ember/tests/dummy/config/targets.js
+++ b/packages/ember/tests/dummy/config/targets.js
@@ -1,10 +1,6 @@
'use strict';
-const browsers = [
- 'last 1 Chrome versions',
- 'last 1 Firefox versions',
- 'last 1 Safari versions'
-];
+const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'];
const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';
@@ -15,5 +11,5 @@ if (isCI || isProduction) {
module.exports = {
browsers,
- node: 'current'
+ node: 'current',
};
diff --git a/packages/ember/tests/helpers/setup-sentry.js b/packages/ember/tests/helpers/setup-sentry.js
index 28de02984f53..7f2f647df50e 100644
--- a/packages/ember/tests/helpers/setup-sentry.js
+++ b/packages/ember/tests/helpers/setup-sentry.js
@@ -7,7 +7,7 @@ import { _instrumentEmberRouter } from '@sentry/ember/instance-initializers/sent
let _routerStartTransaction;
export function setupSentryTest(hooks) {
- hooks.beforeEach(async function() {
+ hooks.beforeEach(async function () {
await window._sentryPerformanceLoad;
window._sentryTestEvents = [];
const errorMessages = [];
@@ -36,12 +36,12 @@ export function setupSentryTest(hooks) {
QUnit.onUncaughtException ? 'onUncaughtException' : 'onUnhandledRejection',
);
- QUnit.onError = function({ message }) {
+ QUnit.onError = function ({ message }) {
errorMessages.push(message.split('Error: ')[1]);
return true;
};
- Ember.onerror = function(...args) {
+ Ember.onerror = function (...args) {
const [error] = args;
errorMessages.push(error.message);
throw error;
@@ -52,7 +52,7 @@ export function setupSentryTest(hooks) {
/**
* Will collect errors when run via testem in cli
*/
- window.onerror = function(error, ...args) {
+ window.onerror = function (error, ...args) {
errorMessages.push(error.split('Error: ')[1]);
if (this._windowOnError) {
return this._windowOnError(error, ...args);
@@ -60,7 +60,7 @@ export function setupSentryTest(hooks) {
};
});
- hooks.afterEach(function() {
+ hooks.afterEach(function () {
this.fetchStub.restore();
this.qunitOnUnhandledRejection.restore();
window.onerror = this._windowOnError;
diff --git a/packages/ember/tests/unit/instrument-route-performance-test.ts b/packages/ember/tests/unit/instrument-route-performance-test.ts
index fbe858e42c36..548a6e819db2 100644
--- a/packages/ember/tests/unit/instrument-route-performance-test.ts
+++ b/packages/ember/tests/unit/instrument-route-performance-test.ts
@@ -2,14 +2,14 @@ import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import Route from '@ember/routing/route';
import { instrumentRoutePerformance } from '@sentry/ember';
-import sinon from 'sinon'
+import sinon from 'sinon';
import { setupSentryTest } from '../helpers/setup-sentry';
-module('Unit | Utility | instrument-route-performance', function(hooks) {
+module('Unit | Utility | instrument-route-performance', function (hooks) {
setupTest(hooks);
setupSentryTest(hooks);
- test('wrapped Route hooks maintain the current context', function(assert) {
+ test('wrapped Route hooks maintain the current context', function (assert) {
const beforeModel = sinon.spy();
const model = sinon.spy();
const afterModel = sinon.spy();
@@ -41,22 +41,22 @@ module('Unit | Utility | instrument-route-performance', function(hooks) {
route.beforeModel('foo');
- assert.ok(beforeModel.calledOn(route), "The context for `beforeModel` is the route");
+ assert.ok(beforeModel.calledOn(route), 'The context for `beforeModel` is the route');
assert.ok(beforeModel.calledWith('foo'), 'The arguments for `beforeModel` are passed through');
route.model('bar');
- assert.ok(model.calledOn(route), "The context for `model` is the route");
+ assert.ok(model.calledOn(route), 'The context for `model` is the route');
assert.ok(model.calledWith('bar'), 'The arguments for `model` are passed through');
route.afterModel('bax');
- assert.ok(afterModel.calledOn(route), "The context for `afterModel` is the route");
+ assert.ok(afterModel.calledOn(route), 'The context for `afterModel` is the route');
assert.ok(afterModel.calledWith('bax'), 'The arguments for `afterModel` are passed through');
route.setupController('baz');
- assert.ok(setupController.calledOn(route), "The context for `setupController` is the route");
+ assert.ok(setupController.calledOn(route), 'The context for `setupController` is the route');
assert.ok(setupController.calledWith('baz'), 'The arguments for `setupController` are passed through');
});
});
diff --git a/packages/ember/types/dummy/index.d.ts b/packages/ember/types/dummy/index.d.ts
index 8b137891791f..e69de29bb2d1 100644
--- a/packages/ember/types/dummy/index.d.ts
+++ b/packages/ember/types/dummy/index.d.ts
@@ -1 +0,0 @@
-
diff --git a/packages/gatsby/gatsby-browser.js b/packages/gatsby/gatsby-browser.js
index 3e2598a0e0b5..5cf1e3d26f80 100644
--- a/packages/gatsby/gatsby-browser.js
+++ b/packages/gatsby/gatsby-browser.js
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const Sentry = require('@sentry/gatsby');
-exports.onClientEntry = function(_, pluginParams) {
+exports.onClientEntry = function (_, pluginParams) {
const isIntialized = isSentryInitialized();
const areOptionsDefined = areSentryOptionsDefined(pluginParams);
diff --git a/packages/nextjs/.eslintrc.js b/packages/nextjs/.eslintrc.js
index bd6ce921c720..857887cc1c15 100644
--- a/packages/nextjs/.eslintrc.js
+++ b/packages/nextjs/.eslintrc.js
@@ -10,5 +10,5 @@ module.exports = {
extends: ['../../.eslintrc.js'],
rules: {
'@sentry-internal/sdk/no-async-await': 'off',
- }
+ },
};
diff --git a/packages/nextjs/test/integration/next.config.js b/packages/nextjs/test/integration/next.config.js
index 9569096fa9ab..c6356f77e3bf 100644
--- a/packages/nextjs/test/integration/next.config.js
+++ b/packages/nextjs/test/integration/next.config.js
@@ -3,7 +3,7 @@ const { withSentryConfig } = require('@sentry/nextjs');
const moduleExports = {
eslint: {
ignoreDuringBuilds: true,
- }
+ },
};
const SentryWebpackPluginOptions = {
dryRun: true,
diff --git a/packages/nextjs/test/integration/test/server/tracingHttp.js b/packages/nextjs/test/integration/test/server/tracingHttp.js
index 6ce6ca14def6..3a00be07899b 100644
--- a/packages/nextjs/test/integration/test/server/tracingHttp.js
+++ b/packages/nextjs/test/integration/test/server/tracingHttp.js
@@ -9,9 +9,7 @@ module.exports = async ({ url: urlBase, argv }) => {
const url = `${urlBase}/api/http`;
// this intercepts the outgoing request made by the route handler (which it makes in order to test span creation)
- nock('http://example.com')
- .get('/')
- .reply(200, 'ok');
+ nock('http://example.com').get('/').reply(200, 'ok');
const capturedRequest = interceptTracingRequest(
{
diff --git a/packages/node/.eslintrc.js b/packages/node/.eslintrc.js
index 35e50dd49832..ce28fd3a0514 100644
--- a/packages/node/.eslintrc.js
+++ b/packages/node/.eslintrc.js
@@ -5,5 +5,5 @@ module.exports = {
extends: ['../../.eslintrc.js'],
rules: {
'@sentry-internal/sdk/no-async-await': 'off',
- }
+ },
};
diff --git a/packages/node/test/manual/memory-leak/context-memory.js b/packages/node/test/manual/memory-leak/context-memory.js
index d9f2361a913f..b7d6abdbcb03 100644
--- a/packages/node/test/manual/memory-leak/context-memory.js
+++ b/packages/node/test/manual/memory-leak/context-memory.js
@@ -20,6 +20,6 @@ for (let i = 0; i < 10000; i++) {
console.log(process.memoryUsage());
-setInterval(function() {
+setInterval(function () {
console.log(process.memoryUsage());
}, 1000);
diff --git a/packages/node/test/manual/memory-leak/express-patient.js b/packages/node/test/manual/memory-leak/express-patient.js
index 430a07e2f64e..4a5ac9bb1895 100644
--- a/packages/node/test/manual/memory-leak/express-patient.js
+++ b/packages/node/test/manual/memory-leak/express-patient.js
@@ -8,14 +8,11 @@ const nock = require('nock');
// have to call this for each request :/ ref https://github.com/node-nock/nock#read-this---about-interceptors
function nockRequest() {
- nock('https://app.getsentry.com')
- .filteringRequestBody(/.*/, '*')
- .post(/.*/, '*')
- .reply(200, 'OK');
+ nock('https://app.getsentry.com').filteringRequestBody(/.*/, '*').post(/.*/, '*').reply(200, 'OK');
}
const memwatch = require('memwatch-next');
-memwatch.on('stats', function(stats) {
+memwatch.on('stats', function (stats) {
process._rawDebug(
util.format(
'gc #%d: min %d, max %d, est base %d, curr base %d',
@@ -71,12 +68,10 @@ app.get('/breadcrumbs/auto/console', (req, res, next) => {
});
app.get('/breadcrumbs/auto/http', (req, res, next) => {
- const scope = nock('http://www.example.com')
- .get('/hello')
- .reply(200, 'hello world');
+ const scope = nock('http://www.example.com').get('/hello').reply(200, 'hello world');
http
- .get('http://www.example.com/hello', function(nockRes) {
+ .get('http://www.example.com/hello', function (nockRes) {
scope.done();
res.textToSend = 'hello there! we got hello world from example.com';
next();
@@ -96,8 +91,8 @@ app.get('/gc', (req, res, next) => {
});
app.get('/shutdown', (req, res, next) => {
- setTimeout(function() {
- server.close(function() {
+ setTimeout(function () {
+ server.close(function () {
process.exit();
});
}, 100);
diff --git a/packages/node/test/manual/memory-leak/manager.js b/packages/node/test/manual/memory-leak/manager.js
index c8b96cf7940a..616c82f8fe26 100644
--- a/packages/node/test/manual/memory-leak/manager.js
+++ b/packages/node/test/manual/memory-leak/manager.js
@@ -24,7 +24,7 @@ function startChild() {
child = child_process.spawn('node', [serverPath]);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
- child.on('exit', function() {
+ child.on('exit', function () {
console.log('child exited');
startChild();
});
diff --git a/packages/node/test/manual/release-health/session-aggregates/aggregates-disable-single-session.js b/packages/node/test/manual/release-health/session-aggregates/aggregates-disable-single-session.js
index 4a78c7d2ea94..3514c834634d 100644
--- a/packages/node/test/manual/release-health/session-aggregates/aggregates-disable-single-session.js
+++ b/packages/node/test/manual/release-health/session-aggregates/aggregates-disable-single-session.js
@@ -13,7 +13,7 @@ function cleanUpAndExitSuccessfully() {
function assertSessionAggregates(session, expected) {
// For loop is added here just in the rare occasion that the session count do not land in the same aggregate
// bucket
- session.aggregates.forEach(function(_, idx) {
+ session.aggregates.forEach(function (_, idx) {
delete session.aggregates[idx].started;
// Session Aggregates keys need to be ordered for JSON.stringify comparison
const ordered = Object.keys(session.aggregates[idx])
diff --git a/packages/node/test/manual/release-health/single-session/terminal-state-sessions-sent-once.js b/packages/node/test/manual/release-health/single-session/terminal-state-sessions-sent-once.js
index deb014ba794e..90f52ef7afbb 100644
--- a/packages/node/test/manual/release-health/single-session/terminal-state-sessions-sent-once.js
+++ b/packages/node/test/manual/release-health/single-session/terminal-state-sessions-sent-once.js
@@ -41,14 +41,14 @@ Sentry.init({
* However we want to ensure that once a crashed terminal state is achieved, no more session updates are sent regardless
* of whether more crashes happen or not
*/
-new Promise(function(resolve, reject) {
+new Promise(function (resolve, reject) {
reject();
-}).then(function() {
+}).then(function () {
console.log('Promise Resolved');
});
-new Promise(function(resolve, reject) {
+new Promise(function (resolve, reject) {
reject();
-}).then(function() {
+}).then(function () {
console.log('Promise Resolved');
});
diff --git a/packages/node/test/manual/release-health/single-session/unhandled-rejection-crashed-session.js b/packages/node/test/manual/release-health/single-session/unhandled-rejection-crashed-session.js
index e955afdbb205..0eea86f3f637 100644
--- a/packages/node/test/manual/release-health/single-session/unhandled-rejection-crashed-session.js
+++ b/packages/node/test/manual/release-health/single-session/unhandled-rejection-crashed-session.js
@@ -42,8 +42,8 @@ Sentry.init({
* extracts event data and uses it to update the Session and sends it. The second session update is sent on the
* `beforeExit` event which happens right before the process exits.
*/
-new Promise(function(resolve, reject) {
+new Promise(function (resolve, reject) {
reject();
-}).then(function() {
+}).then(function () {
console.log('Promise Resolved');
});
diff --git a/packages/serverless/.eslintrc.js b/packages/serverless/.eslintrc.js
index 35e50dd49832..ce28fd3a0514 100644
--- a/packages/serverless/.eslintrc.js
+++ b/packages/serverless/.eslintrc.js
@@ -5,5 +5,5 @@ module.exports = {
extends: ['../../.eslintrc.js'],
rules: {
'@sentry-internal/sdk/no-async-await': 'off',
- }
+ },
};
diff --git a/packages/types/.eslintrc.js b/packages/types/.eslintrc.js
index 4aa0b7074fb2..da4b0f29f027 100644
--- a/packages/types/.eslintrc.js
+++ b/packages/types/.eslintrc.js
@@ -2,5 +2,5 @@ module.exports = {
extends: ['../../.eslintrc.js'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
- }
+ },
};
diff --git a/packages/utils/test/types/index.js b/packages/utils/test/types/index.js
index 6fd6277f70bf..5ff997d32269 100644
--- a/packages/utils/test/types/index.js
+++ b/packages/utils/test/types/index.js
@@ -15,7 +15,7 @@ paths.forEach(dir => {
files.forEach(file => {
if (file.includes('.d.ts')) {
testStrings.forEach(testString => {
- const filePath = path.join(dir, file)
+ const filePath = path.join(dir, file);
if (fs.readFileSync(filePath, 'utf8').includes(testString)) {
// eslint-disable-next-line no-console
console.error(`${filePath} contains types`);
diff --git a/scripts/craft-pre-release.sh b/scripts/craft-pre-release.sh
index bbda7bb6ef12..75df3de94eef 100755
--- a/scripts/craft-pre-release.sh
+++ b/scripts/craft-pre-release.sh
@@ -2,12 +2,12 @@
set -eux
# Move to the project root
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $SCRIPT_DIR/..
OLD_VERSION="${1}"
NEW_VERSION="${2}"
- # Do not tag and commit changes made by "npm version"
+# Do not tag and commit changes made by "npm version"
export npm_config_git_tag_version=false
yarn install --frozen-lockfile