Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TraceKit can now be used on frames #68

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach Karma Chrome",
"address": "localhost",
"port": 9333,
"pathMapping": {
"/": "${workspaceRoot}/",
"/base/": "${workspaceRoot}/"
},
"webRoot": "${workspaceRoot}/"
},
{
"type": "chrome",
"request": "launch",
"name": "Test",
"sourceMaps": true,
"webRoot": "${workspaceRoot}/",
"url": "http://localhost:9333/debug.html",
"runtimeArgs": [
"--headless"
]
}
]
}
66 changes: 0 additions & 66 deletions Gruntfile.js

This file was deleted.

73 changes: 73 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* jshint esversion: 6 */
/* jshint node: true */
const gulp = require('gulp');
const Server = require('karma').Server;
const jshint = require('gulp-jshint');
const bump = require('gulp-bump');

const srcCode = ['./tracekit.js'];
/**
* Run test once and exit
*/
gulp.task('test', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});

/**
* Watch for file changes and re-run tests on each change
*/
gulp.task('tdd', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js'
}, done).start();
});

/**
* Watch for file changes and re-run tests on each change
*/
gulp.task('tddchrome', function (done) {
new Server({
configFile: __dirname + '/karma.conf.chrome.js'
}, done).start();
});

// We do this over using include/exclude to make everything feel gulp-like!
gulp.task('doc', function (cb) {
let jsdoc = require('gulp-jsdoc3');

let config = require('./jsdoc.conf.json');
gulp.src(['README.md'].concat(srcCode), {
read: false
})
.pipe(jsdoc(config, cb));
});


gulp.task('lint', function () {
return gulp.src(['./tracekit.js', './Gulpfile.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});


// Update bower, component, npm at once:
gulp.task('bump', function () {
gulp.src(['package.json', 'bower.json', 'appveyor.yml'])
.pipe(bump({
type: 'patch'
}))
.pipe(gulp.dest('./'));
});


// Update bower, component, npm at once:
gulp.task('bump-minor', function () {
gulp.src(['package.json', 'bower.json', 'appveyor.yml'])
.pipe(bump({
type: 'minor'
}))
.pipe(gulp.dest('./'));
});
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-tactile
6 changes: 5 additions & 1 deletion jsdoc.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
},
"plugins": [
"plugins/markdown"
]
],
"opts": {
"destination": "./doc/",
"recurse": true
}
}
75 changes: 75 additions & 0 deletions karma.conf.chrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Karma configuration

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
plugins: [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-chrome-launcher'
],

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'tracekit.js',
'spec/**/*.js'
],


// list of files to exclude
exclude: [
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9333,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeDebugging'],

customLaunchers: {
ChromeDebugging: {
base: 'Chrome',
flags: ['--remote-debugging-prt=9333'],
debug: true
}
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
})
};
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(config) {


// web server port
port: 9876,
port: 9333,


// enable / disable colors in the output (reporters and logs)
Expand Down
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
],
"license": "MIT",
"devDependencies": {
"grunt": "1.0.1",
"grunt-bump": "^0.8.0",
"grunt-cli": "1.2.0",
"grunt-contrib-jasmine": "1.1.0",
"grunt-contrib-jshint": "1.1.0",
"grunt-jsdoc": "2.1.0",
"jasmine": "2.6.0",
"jasmine-core": "2.6.4",
"karma": "1.7.0",
"karma-jasmine": "1.1.0",
"gulp": "3.9.1",
"gulp-jsdoc3": "^2.0.0",
"gulp-jshint": "^2.1.0",
"jasmine": "3.1.0",
"jasmine-core": "3.1.0",
"jsdoc": "3.5.5",
"jshint": "^2.9.5",
"karma": "2.0.4",
"karma-chrome-launcher": "2.2.0",
"karma-jasmine": "1.1.2",
"karma-phantomjs-launcher": "1.0.4",
"phantomjs-prebuilt": "2.1.14"
"phantomjs-prebuilt": "2.1.16"
},
"scripts": {
"test": "grunt test"
"test": "gulp test"
},
"typings": "tracekit.d.ts",
"author": "Blake Niemyjski <[email protected]>"
"author": "Blake Niemyjski <[email protected]>",
"dependencies": {
"gulp-bump": "^3.1.1"
}
}
10 changes: 10 additions & 0 deletions spec/support/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"spec_dir": "spec",
"spec_files": [
"*[sS]pec.js"
],
"helpers": [
"../spec/fixtures/captured-errors.js",
"../tracekit.js"
]
}
4 changes: 3 additions & 1 deletion spec/tracekit-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
if (message === testMessage || lineNo === testLineNo) {
return true;
}
return oldOnErrorHandler.apply(this, arguments);
if (oldOnErrorHandler) {
return oldOnErrorHandler.apply(this, arguments);
}
};
});

Expand Down
27 changes: 27 additions & 0 deletions tracekit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ export interface StackFrame {
context:string[];
}

declare global {
interface Window {
onunhandledrejection: PromiseRejectionEvent;
_onErrorHandlerInstalled : boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to expose this private var?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.

}
interface Error {
columnNumber: number;
stacktrace : string;
description : string;
sourceURL : string;
fileName: string;
line : number;
lineNumber : number;
}
}

export interface StackTrace {
/**
* Known modes: callers, failed, multiline, onerror, stack, stacktrace
Expand All @@ -17,8 +33,19 @@ export interface StackTrace {
url:string;
stack:StackFrame[];
useragent:string;
incomplete?: boolean;
partial?: boolean;
}

export interface TraceKit {
/**
* stacktrace
*/
StackTrace:StackTrace;
}



interface ComputeStackTrace {
/**
* Computes a stack trace for an exception.
Expand Down
Loading