Socket
Socket
Sign inDemoInstall

karma-jasmine-diff-reporter

Package Overview
Dependencies
142
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.3.3

2

package.json
{
"name": "karma-jasmine-diff-reporter",
"version": "0.3.2",
"version": "0.3.3",
"description": "Karma reporter to highlight diffs of failed equality expectations for Jasmine",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -242,2 +242,3 @@ karma-jasmine-diff-reporter

- 0.3.3 - Detect stack trace for PhantomJS
- 0.3.2 - Override default colors

@@ -244,0 +245,0 @@ - 0.3.1 - Detect newlines in strings.

@@ -131,2 +131,20 @@ 'use strict';

// Check if character on position "index" is inside a string
function isInsideString(string, index) {
// Validate index if it is out of valid range
if (index > string.length - 1 || index < 0) {
return false;
}
// Count number of string markers starting from character position
// If it is odd - that means that character is inside the string
var markersCount = 0;
var markerIndex = index;
while ((markerIndex = string.indexOf(MARKER, markerIndex + 1)) > -1) {
markersCount += 1;
}
return markersCount % 2 !== 0;
}
function pretty(str, indent) {

@@ -179,19 +197,23 @@ var out = '';

// So it would be easier to detect newlines in Jasmine message
var messageParts = message.split('\n');
var matcherMessage = message;
var stackMessage = '';
var matcherParts = [];
var stackParts = [];
messageParts.forEach(function (messagePart) {
if (STACK_PATTERN.test(messagePart)) {
stackParts.push(messagePart);
} else {
matcherParts.push(messagePart);
// Find last dot+newline in the entire message, it should be a place
// where stacktrace starts. Verify it by testing whether or not this dot
// is inside a string, it can be done by checking string markers.
// If there is no any strings inside the message, then it is a position
// of a stack trace for sure.
var dotIndex = message.length;
do {
dotIndex = message.lastIndexOf('.\n', dotIndex - 1);
if (!isInsideString(message, dotIndex)) {
break;
}
});
} while (dotIndex != -1);
// Use matcherMessage for futher manipulations like diff
// Then append it with stackMessage to get an original-like result
var matcherMessage = matcherParts.join('\n');
var stackMessage = stackParts.join('\n');
// If stacktrace start position found - separate it from Jasmine message
if (dotIndex !== -1) {
matcherMessage = message.substr(0, dotIndex + 1);
stackMessage = message.substr(dotIndex + 1, message.length);
}

@@ -297,3 +319,3 @@

// Compose final message
var resultMessage = [diffedMatcherMessage, stackMessage].join('\n');
var resultMessage = diffedMatcherMessage + stackMessage;

@@ -300,0 +322,0 @@ return resultMessage;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc