mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
Rewrite sentry.js as CommonJS, add basic test
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
7
assets/static/sentry.test.js
Normal file
7
assets/static/sentry.test.js
Normal 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();
|
||||
});
|
||||
Reference in New Issue
Block a user