Rewrite sentry.js as CommonJS, add basic test

This commit is contained in:
Łukasz Mierzwa
2017-07-21 22:04:51 -07:00
parent d083054409
commit 7301f40778
2 changed files with 21 additions and 17 deletions

View File

@@ -1,19 +1,16 @@
/* globals Raven */ // raven.js
const Raven = require("raven-js");
const $ = require("jquery");
(function() {
// init sentry client if sentry dsn is set
if ($("body").data("raven-dsn")) {
var dsn = $("body").data("raven-dsn");
// raven itself can fail if invalid DSN is passed
try {
Raven.config(dsn, {
release: $("body").data("unsee-version")
}).install();
} catch (error) {
var msg = "Sentry error: " + error.message;
$("#raven-error").text(msg).removeClass("hidden");
}
// init sentry client if sentry dsn is set
if ($("body").data("raven-dsn")) {
var dsn = $("body").data("raven-dsn");
// raven itself can fail if invalid DSN is passed
try {
Raven.config(dsn, {
release: $("body").data("unsee-version")
}).install();
} catch (error) {
var msg = "Sentry error: " + error.message;
$("#raven-error").text(msg).removeClass("hidden");
}
})();
}

View File

@@ -0,0 +1,7 @@
test("sentry loaded", () => {
document.body.setAttribute("data-raven-dsn", "123");
document.body.setAttribute("data-unsee-version", "0.1.2");
require("./sentry");
const Raven = require("raven-js");
expect(Raven.lastEventId()).toBeNull();
});