Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json rendered in test console not useable? #4

Open
Michael-Tajmajer-Emrsn opened this issue Sep 7, 2017 · 4 comments
Open

Json rendered in test console not useable? #4

Michael-Tajmajer-Emrsn opened this issue Sep 7, 2017 · 4 comments
Labels

Comments

@Michael-Tajmajer-Emrsn
Copy link

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?

@Michael-Tajmajer-Emrsn
Copy link
Author

It seems that the newlines (\n) are the culpret here.

maybe the json displayed in the browser can encode special characters and do the same when it compares the xml?

Otherwise, thanks for such a helpful library!

@horvay
Copy link
Owner

horvay commented Sep 8, 2017

I'll have to test this myself and see about encoding.

For now, I have to deal with an Irma :P

@horvay horvay added the bug label Sep 8, 2017
@jtisekar
Copy link
Contributor

I ran into the same issue and found that the exception gets thrown when the snapshot library reads an existing snapshot which has a \n in it. The workaround I found is that in the saved snapshot change all '\n' to '\n' to escape them.

When reading a saved snapshot, the \n gets parsed and the json gets split into multiple lines and the parsing on the json fails.
@horvay will you be able to look into it ? Not sure if the issue is here or in vkbeautify

@horvay
Copy link
Owner

horvay commented Mar 31, 2018

I definitely need to look into this. I've just been so busy, and this week is especially bad. I'll put a reminder for myself to look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants