Better Formatting for JSON Files (#12)

This commit is contained in:
Joshua 2023-05-28 14:02:59 +02:00 committed by GitHub
parent 897ad51548
commit f9f95315fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 8 deletions

View file

@ -1 +1,8 @@
{"data":[1,2,3]}
{
"data": [
1,
2,
3,
4
]
}

View file

@ -1 +1,3 @@
{"data":42}
{
"data": 42
}

View file

@ -1 +1,4 @@
{"foo":"bar","Fizzy Drink":"Pop"}
{
"foo": "bar",
"Fizzy Drink": "Pop"
}

View file

@ -1 +1,4 @@
{"foo":"bar","Fizzy Drink":"Soda"}
{
"foo": "bar",
"Fizzy Drink": "Soda"
}

View file

@ -1 +1,3 @@
{"data":"foo-bar"}
{
"data": "foo-bar"
}

View file

@ -1,7 +1,7 @@
{
"name": "@datashard/snapshot",
"description": "Adds value / object / DOM element snapshot testing support to Cypress test runner",
"version": "2.2.1",
"version": "2.2.2",
"author": "Joshua <data@shard.wtf>, Gleb Bahmutov <gleb@cypress.io>",
"bugs": "https://github.com/datashard/snapshot/issues",
"engines": {

View file

@ -16,7 +16,7 @@ const newStore = (name) => {
return initStore(name);
};
const store_snapshot = (store, props = { value, name, path, raiser }) => {
const store_snapshot = (store, props = { value, name, path, raiser}) => {
const expectedPath = path.join(
props.path ||
Cypress.config("snapshot").snapshotPath ||
@ -27,7 +27,7 @@ const store_snapshot = (store, props = { value, name, path, raiser }) => {
if (exist && !Cypress.env().SNAPSHOT_UPDATE) {
props.raiser({ value: props.value, expected: JSON.parse(exist) });
} else {
cy.writeFile(expectedPath, JSON.stringify(props.value));
cy.writeFile(expectedPath, JSON.stringify(props.value, null, 2));
}
});
};