GithubHelp home page GithubHelp logo

horvay / jasmine-snapshot Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 7.0 282 KB

This allows you to compare snapshots to html or javascript objects

License: MIT License

TypeScript 82.09% JavaScript 11.05% Python 6.87%

jasmine-snapshot's People

Contributors

horvay avatar jtisekar 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

Watchers

 avatar  avatar  avatar

jasmine-snapshot's Issues

TypeError: Cannot read property 'unifiedDiff' of undefined

Heya

Tried to pull this in on a react project using jasmine and got the titular error

I think there's a problem with how you are importing difflib.
I see from jasmine-snapshot/src/index.ts that you are importing the default export in es6
import difflib from 'difflib';

But in difflib/src/difflib.coffee it doesn't use the module syntax, so it looks like there's no default export

Went and mucked with the minified, transpiled source in jasmine-snapshot.min.js to change from difflib.default.unifiedDiff to difflib.unifiedDiff and it started working

Obviously changing minified code is sketch but maybe index.ts should read import * as difflib from 'difflib'?

Json rendered in test console not useable?

The Json generated in the web browser (runner) is causing an exception when I cut and paste it into my test.

If actual is valid, update your snapshot with the following
{
"markup matches snapshot with Good Status 1": { "div": { "_class": "root-container", "_data-hitid": "dispel2", "_data-modelid": "dispel2", "_style": "left: 0px; top: 0px; width: 100px; height: 36px; opacity: 1;", "div": { "_style": "position: relative; width: 100%; height: 100%;", "div": { "_class": "visualOverflowHidden", "_style": "opacity: 1; line-height: normal; text-decoration: none; height: 100%; width: 100%; overflow: hidden; border-style: solid; border-width: 0px; font-size: 12px; font-family: \\\"Segoe UI\\\"; font-weight: normal; font-style: normal;", "div": { "_style": "width: 100%; height: 100%; cursor: default; text-decoration: none; display: flex; flex-direction: row; justify-content: flex-end;", "div": { "__text": "Good Data", "_style": "max-width: 100px; overflow: hidden; width: 100%; text-align: right;", "_title": "" } }, "style": { "__text": "input {\n border: 0\n}\n \n\n*:focus {\n outline: none;\n}" } } } }},

Expected function not to throw, but it threw SyntaxError: Unexpected token in JSON at position 831.

I'm not quite sure what the issue is?

Doesn't work with jasmine node CLI

I'd like to use this snapshot library with the "jasmine" node CLI as well as in the browser. Could you add some checks so I don't run into "window is not defined" and "document is not defined"? (I'm trying to switch from jest to Jasmine, and want to have a single test suite that works in both environments.)

Change reporter to not wipe out the existing body content

Hi.

I've just started using this after reading about Jest. It works really well and I do like the diffs it produces.
I just find it annoying that it replaces the whole body tag with it's report, as it removes the content from the htmlReporter. I've hacked it around for the moment to prepend the content to the top for now.

In jasmineDone I replaced
document.body.innerHTML = html_summary;
with
document.body.innerHTML = html_summary + document.body.innerHTML;

That's a nice quick workaround, but I was wondering if it's possible to add the diff and new snapshot to the result object instead? This would mean that the results are usable in any reporter.

Thanks

Multiple snapshots for same test

I am using karma & jasmine to test some web components. I am trying to add snapshot testing via jasmine-snapshot. I was able to get a snapshot test working for the most part, but am running into a slight issue when running multiple browsers. I am running the tests in both firefox & chrome, and since web components are not natively supported in firefox, I am having to use a polyfill for the shadow dom. Unfortunately, this causes chrome & firefox to have a slightly different HTML structure (there are some additional classes added on firefox, which are not there in chrome, for the shadow dom polyfill).

Is there some way to allow multiple snapshots for a test? This actually sparked a workaround in my head, to sniff the user agent and add the snapshot in a conditional statement.

Also, some additional documentation on registering the snapshots in the README would be great.

Thanks for putting together this library btw!

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.