New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

karma-stacktrace

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-stacktrace

Provides readable mapped stacktrace for failed tests to debug the them in your browser.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-20.39%
Maintainers
1
Weekly downloads
 
Created
Source

karma-stacktrace

npm GitHub license

What

Provides readable mapped stacktrace for failed tests to debug the them in your browser.

Motivation

Test frameworks like QUnit and Jasmine use non-standard stack property of Error object to output a stacktrace for failed unit tests. Modern browsers do not apply sourcemaps to Error.prototype.stack and unmapped stacktrace looks useless.

An example of an unmapped stacktrace:

Original stacktrace

The framework catches failed tests and reports mapped stacktrace by using stacktrace-js library:

Mapped stacktrace

Install

Install with yarn:

yarn add karma-stacktrace

With npm:

npm install karma-stacktrace

Karma configuration

Add stacktrace to the list of frameworks for a corresponding karma configuration:

// karma.conf.js
module.exports = function(config) {
  config.set({
    //...
    frameworks: ['stacktrace'],
    //...
  });
};

To avoid blocking the main execution thread of a web application Web Workers are used by default for parsing/mapping stacktrace, however you can disable it (you might need it for inline sourcemaps):

// karma.conf.js
module.exports = function(config) {
  config.set({
    //...
    client: {
      stacktrace: {
        useWorker: false
      }
    },
    //...
  });
};

Limitations/Gotchas

  • At the moment the framework supports only Jasmine and QUnit testing frameworks.
  • The framework attaches isolated reporters to trace mapped stacktrace, it does not affect stacktrace in original messages.
  • It is recommended to set useWorker option to false value for inline sourcemaps to get mapped stacktrace.

Examples

See examples folder for details.

Inspired by

Keywords

FAQs

Package last updated on 18 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc