diff --git a/README.md b/README.md index 883bc45..bf020e6 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This will register a new Command `.snapshot()`, to create new Snapshots and once ## Config You can pass `updateSnapshots` and `useFolders` as options in the `cypress.config.js` file - +![Example Settings for the Module](./.github/assets/config.png) Alternatively, you can also add `snapshotUpdate` as an Environment Variable to update your snapshots. @@ -75,4 +75,5 @@ If a step wasn't named, it will instead use the ``for the file name, though Of course, if a value changed, it will no longer match the snapshot and throw an Error. -![](./.github/assets/Error.png) \ No newline at end of file +![](./.github/assets/Error.png) + diff --git a/cypress.config.js b/cypress.config.js index b774daf..9301451 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,7 +1,7 @@ const { defineConfig } = require("cypress"); module.exports = defineConfig({ - + fixturesFolder: "cypress/fixtures", snapshot: { // updateSnapshots: true, useFolders: true, diff --git a/src/snapshot.js b/src/snapshot.js index 1dc6c74..41b369b 100644 --- a/src/snapshot.js +++ b/src/snapshot.js @@ -22,9 +22,10 @@ const parseTextToJSON = (text) => text.replace(/\| [✅➖➕⭕]/g, "").trim(). const store_snapshot = (props = { value, name, raiser }) => { if (Cypress.env().updateSnapshots || Cypress.config('snapshot').updateSnapshots) { cy.SNAPSHOT_prettyprint({ title: "INFO", type: "info", message: "Saving Snapshot" }) - cy.writeFile(`${props.name}.json`, JSON.stringify(props.value, null, 2)) + cy.writeFile(`${Cypress.env().fixturesFolder}/${props.name}.json`, JSON.stringify(props.value, null, 2)) } else { // TODO: Figure out how to replace the fixture folder name if people move it + // const fixtureName = props.name.replace(Cypress.env().fixturesFolder, "") const fixtureName = props.name.replace("cypress/fixtures", "") cy.fixture(fixtureName).then(content => props.raiser({ value: props.value, expected: content })) } diff --git a/undefined/cypress/fixtures/snapshots/datashard-snapshot/simple-types/works-with-arrays.json b/undefined/cypress/fixtures/snapshots/datashard-snapshot/simple-types/works-with-arrays.json new file mode 100644 index 0000000..dc8d53f --- /dev/null +++ b/undefined/cypress/fixtures/snapshots/datashard-snapshot/simple-types/works-with-arrays.json @@ -0,0 +1,8 @@ +{ + "data": [ + 1, + 2, + 3, + 4 + ] +} \ No newline at end of file