horvay / jasmine-snapshot Goto Github PK
View Code? Open in Web Editor NEWThis allows you to compare snapshots to html or javascript objects
License: MIT License
This allows you to compare snapshots to html or javascript objects
License: MIT License
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'
?
I found this other library:
https://github.com/bahmutov/snap-shot-it
authored by one of the developers of Cypress which he blogs about here.
It claims to be test framework-agnostic and lets you work with multiple, named snapshots.
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?
If I have a div that contains , the match always succeeds!
When I remove the it works as expected.
strange!
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.)
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
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.