Code Monkey home page Code Monkey logo

karma-jasmine-diff-reporter's People

Contributors

eug- avatar havunen avatar ilanfrumer avatar mradionov avatar nkbt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

karma-jasmine-diff-reporter's Issues

Separate diffed objects and matcher text with new lines to improve readability

Based on PR #11

Add new option to enhance the output of error messages by adding extra indents and new lines between matcher text and diffed objects.

Matcher initial text ...

  object1

Matcher middle text ...

  object2

Matcher end text ...

Examples:

Expected

  foo

to equal

  bar

Expected

  Object({
    foo: 'bar' 
  })

to equal

  Object({
    baz: 'qux' 
  })

Expected function to throw

  TypeError: boo

but it threw

  ReferenceError: a is not defined

Objects should be equally indented comparing to matcher's initial, middle and end text. Because of it pretty print feature should also be tweaked a bit. It might also require some work with matcher default text, because for example toHaveBeenCalledWith wraps objects in array and it looks different from other matchers.

Additional characters appearing in diff output for string data

I'm getting additional characters (a "ÔÇî" sequence) appearing in the output when displaying string data, both in our test suite and the demo one provided.

Environment:
Windows 7 (64 bit)
Node.js 4.2.3 LTS
Karma 0.13.19
Karma-Jasmine: 0.3.7

The attached output is from powershell hosted in the "cmder" utility, although similar results occur in cmd.exe (with "?" appearing instead).

output.txt

When running in a normal Powershell window or Git Bash the additional characters do not display or appear in the output.

I'll do some more digging to see if I can isolate the issue.

Diff is selecting stack trace

As can be seen in this screenshot:

screen shot 2016-02-01 at 4 15 31 pm

The diff reporter is selecting stack the trace. This is when using karma 0.12.37 and PhantomJS 2.1.1.

Cannot prettify objects in results

Hi,

I'm trying to display results like in the documentation:

(http://i.imgur.com/6TTlSmB.jpg)

Changing colors and verbose works well, but pretty has no effect. All the following settings display objects on only one line:

pretty: true
pretty: '\t'
pretty: 2
multiline: {
  before: 3,
  after: '\n',
  indent: '  '
}
pretty: true,
multiline: true

Thanks for help.

Suppress console logs

I would like to be able to use this and suppress output from all console.log statements. I use a few other reporters in conjunction with this one and I am seeing all my log outputs twice in the console

Add a Function difference

When have have two Function into an object that we compare, the Function's are not highlighted.

We were talking a bit about it in #17.

I suggest adding a new color (by default it would be orange?) that when we compare Function to Function both would be in that color to lift up a flag that it could be different.

Also, regarding this, I would consider jasmine.any(Function) and Function the same and therefore not show any colors at all.

Empty object is displayed with random colon

Empty object is displayed with a colon and extra space.

Default options:

image

pretty: true, multiline: true

image

verbose: false

image

Empty array has two spaces inside, maybe it can be fixed along the way as well.

Override defaults.

At the moment defaults set bgColor. I'd prefer to ser text color instead. Something like:

20160117-193556

Unfortunately chald does not have "bgDefault" or something, so if I set bgBlack it actually becomes black, which is not working very well on default grey bg:

20160117-193945

I suggest to allow to pass undefined color that will allow to "not set" bg colors.

So instead of

  var styles = [
    color.actualBg || 'bgGreen',
    color.actualFg || 'white'
  ];

I see it like:

  var styles = [
    color.hasOwnProperty('actualBg') ? color.actualBg : 'bgGreen',
    color.hasOwnProperty('actualFg') ? color.actualBg : 'white'
  ];

warning message: File "/jasmine-core/jasmine.js" not found in module "jasmine-core".

I have this warning message tell me i can't use the pretty print option which i will like to use
here is all the karma plugin i have:
"jasmine-core": "2.5.2",
"karma": "1.1.2",
"karma-angular-filesort": "0.1.0",
"karma-chrome-launcher": "1.0.1",
"karma-coverage": "1.1.1",
"karma-jasmine": "1.0.2",
"karma-jasmine-diff-reporter": "0.6.2",
"karma-junit-reporter": "1.1.0",
"karma-phantomjs-launcher": "1.0.1",
"karma-threshold-reporter": "0.1.15",

Newlines break string highlighting

See:

String with Newline Breaks Highlighting

The first test, in which the compared strings have no newlines, highlights correctly.

The two additional failing tests, although they are failing because string comparison failed, don't highlight.

Request: An option to show "undefined" value as a string (JSON mode)

Hi there,

Would it be possible that you add an option that we could set to true to allow undefined values in the JSON output.

By default, JSON.stringify removes all undefined value, so we would have to replace it with a undefined string.

So let's say we have the following :

var obj1 = {Foo: 'Foo', Bar: undefined};
var obj2 = {Foo: 'Foo'};

console.log(JSON.stringify(obj1));
// '{"Foo": "Foo"}'
console.log(JSON.stringify(obj2));
// '{"Foo": "Foo"}'

So it would do this while testing, but we cannot see why it is not passing :

Expected '{"Foo": "Foo"}' to equal '{"Foo": "Foo"}'

Default colors suggestion

Perhaps it's only due to my terminal settings, but I couldn't use the reporter with its out-of-the-box color configuration.

It looked like this:
2016-08-25 13 57 37

I changed my color configuration to the following:

color: {
    actualFg: 'red',
    expectedFg: 'green',
    actualBg: 'inverse',
    expectedBg: 'inverse',
    actualWhitespaceBg: '',
    expectedWhitespaceBg: '',
}

And it looked like this.
2016-08-25 13 57 51

I believe the inverse setting is a better choice by virtue of it using the terminal's default background color as its foreground color. The background color generally would have high contrast next to colors such as green and red, as text rendered in green and red would have to be visible against the background in the first place.

Instructions for installing & using seem to be incomplete, throwing ERROR

Following the example in the README.md:

$ npm install karma-jasmine-diff-reporter --save-dev
[email protected] ~/github/my-project
└── [email protected]

and

reporters: ['jasmine-diff', 'progress', 'coverage'],

results in:

Running "karma:unit" (karma) task
14 09 2017 14:07:29.870:ERROR [reporter]: Can not load reporter "jasmine-diff", it is not registered!
  Perhaps you are missing some plugin?
14 09 2017 14:07:30.133:ERROR [karma]: Found 1 load error

Spaces in strings not show in diff

For instance, if you do:

expect('test  test').toEqual('test test')

The output is:
image

In this example, it's quite obvious but in a big diff it can get tricky...

I understand that this is not a bug but just that the extra space is actually colored but not visible.

A solution might be to replace spaces that are different by the ␣ character or by another one.

DEPRECATION: jasmine.matchersUtil is deprecated and will be removed in a future release

The following deprecation notice is shown when I use this reporter:

DEPRECATION: jasmine.matchersUtil is deprecated and will be removed in a future release. Use the instance passed to the matcher factory or the asymmetric equality tester's `asymmetricMatch` method instead. See <https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#static-utils> for details.
    at <Jasmine>
    at matchersUtilPatched (http://localhost:9876/base/node_modules/karma-jasmine-diff-reporter/src/karma-jasmine/util-patch.js?24ebf18c87e51712a9f46a9365bf0873ee5ebc85:11:17)
    at http://localhost:9876/base/node_modules/karma-jasmine-diff-reporter/src/karma-jasmine/util-patch.js?24ebf18c87e51712a9f46a9365bf0873ee5ebc85:8:31
    at http://localhost:9876/base/node_modules/karma-jasmine-diff-reporter/src/karma-jasmine/util-patch.js?24ebf18c87e51712a9f46a9365bf0873ee5ebc85:28:2
Note: This message will be shown only once. Set the verboseDeprecations config property to true to see every occurrence.'

image

Pretty print

Implement pretty print option, as it was suggested here: http://stackoverflow.com/a/32280598/1573638

  • option in reporter configuration to turn on/off pretty print
jasmineDiff: {
    pretty: true
    pretty: false (default)
    pretty: function (objString) {
        return JSON.stringify(objString, null, 4);
    }
}
  • option to turn on/off pretty print for particular matchers (and custom matchers), because in case of toThrow and toThrowError pretty print is useless.
  • use only for objects (arrays)

Jasmine 2.6 released with it's own diff

Jasmine finally got it's own version of "pretty print" for objects, which is available from version 2.6.0, and you are probably using that same version. That would be the reason why you might not have an output, which was expected from my reporter. Now it will look like this:

Expected object to have properties
    b: 43
Expected object not to have properties
    a: 42
    at Object.<anonymous> (spec/test.test.js:3:27)

Here is original issue in Jasmine rep: jasmine/jasmine#675 and respective PR jasmine/jasmine#1163.

I have to think about what to do next, because I did not expect it to happen this soon and I've just recently completed a major rewrite of the reporter. Probably I'll just keep it as is, so it will work only with Jasmine versions prior 2.6, because I have no idea how they are gonna continue improving their diff output and it might be difficult to adapt to from my side.

Thank you for your report, if you really want to use this reporter at full capacity, the only thing for now is to downgrade Jasmine to 2.5, but I am not insisting on it in any ways, because Jasmine might have things fixed and improved in latest versions.

Another option might be to introduce an option in my reporter to ignore new Jasmine 2.6 diff output and bring back old 2.5 output by monkey-patching Jasmine, what I already do anyways, but it will also allow reporter to continue working as before.

Breaking change: Make legacy flag true by default

I guess every user who wants to use a reporter has to always enable legacy mode, otherwise reporter is useless for Jasmine 2.6 + users (see readme). I can just simply enable it by default, there is no reason to keep at as an option. It will require a major version bump.

Colors not working but Pretty is

I'm using the packages below and while pretty works, the colors do not. I have tried pruning down my karma file to only include the bare essentials and to no avail the colors wouldn't show up.

    "grunt-karma": "^2.0.0",
    "jasmine-core": "^2.2.0",
    "karma-jasmine-diff-reporter": "^0.6.2"
var web_dependencies = require('./web_dependencies');

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    browsers: ['Chrome'],

    files: web_dependencies.concat([
      ...
    ]),

    ngHtml2JsPreprocessor: {
      stripPrefix: 'public',
      moduleName: 'templates'
    },

    reporters: ['jasmine-diff'],


    jasmineDiffReporter: {
      pretty: true
    },

    colors: true
  });
};

It's worth noting that my terminal window does show other colors:
screen shot 2016-10-31 at 1 07 21 pm

Diff in jasmine.objectContaining

When we compare:
expect(res).toEqual(jasmine.objectContaining(result));

And when only one key have not the same we can see 2 or above differences

Thanks :)

image

TypeError: Cannot read properties of undefined (reading 'equals') with Jasmine 4.2

When trying to run our tests with Jasmine 4.2, I get the following error:

TypeError: Cannot read properties of undefined (reading 'equals')

The error is coming from util-patch.js:

function matchersUtilPatched(j$) {
  var util = j$.matchersUtil;
  var oldEquals = util.equals.bind(util); // <--- crashes here because util is undefined
...

According to Jasmine 4 upgrade notes jasmine.matchersUtil is deprecated and apparently has been removed now.

Duplicate output with `legacy` option on.

Moved from comment: #27 (comment)

I'm getting duplicate output with these settings, is that expected? Is that what you mean by "bring back old output and reporter highlights as well"? If so, any chance this can be changed to show only the diff reported output?

image

TypeError: value.and.identity is not a function

Hello,
i am getting this very strange error:

TypeError: value.and.identity is not a function in node_modules/karma-jasmine-diff-reporter/src/karma-jasmine/pp-patch.js (line 82)

I am using these karma dependencies:

    "karma": "2.0.0",
    "karma-angular-filesort": "1.0.2",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage": "1.1.1",
    "karma-firefox-launcher": "1.1.0",
    "karma-jasmine": "1.1.1",
    "karma-jasmine-diff-reporter": "1.1.1",
    "karma-jasmine-matchers": "3.7.0",
    "karma-junit-reporter": "1.2.0",
    "karma-ng-html2js-preprocessor": "1.0.0",
    "karma-ng-pug2js-preprocessor": "1.0.0-beta.0",
    "karma-safari-launcher": "1.0.0",
    "karma-spec-reporter": "0.0.31",

Could you please advice what is wrong?

Thank you!

Andrej

Show diff with toContain() method

There is jasmine's toContain() method which check whether string (or an array) is containing sub-string. Any chance to show diff highlighting for this?

I understand, that this will also show me highlighted extra characters of parent string, but this is very ok for me. Even in this case, it vill be much easier for me to recognize the issue.

Space in object key not displayed

Spaces in key names are not displayed in the diff report. This can result in a failing test with no diff highlighted by the reporter. Not sure if this is a bug or a configuration issue?

Recreate:

it('should have a space in the key', () => {
expect({ hithere: true }).toEqual({ 'hi there': true });
});

The test will correctly fail but the reporter will print the following result:

Expected
Object({ hithere: true })
to equal
Object({ hithere: true })

The reporter settings:

jasmineDiffReporter: {
pretty: true,
multiline: true,
matchers: {
toContain: {
pattern: /Expected ([\S\s]*) to contain ([\S\s]*)\./,
reverse: false
}
}
}

Running with dots reporter:

reporters: ['jasmine-diff', 'dots']

Diffs in "mocha" mode

Show diffs like mocha does: https://mochajs.org/#diffs

reporter-string-diffs

  • display single object with added/removed parts in it next to each other, instead of two separate objects
  • modify default Jasmine error messages and replace with custom ones
  • config option to turn on/off the feature (for entire reporter and for particular matchers)
jasmineDiff: {
  merge: true
  merge: false
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.