mirror of
https://github.com/datashard/snapshot.git
synced 2024-11-24 06:42:29 +00:00
working code
This commit is contained in:
parent
d45d7479f0
commit
930662045c
4 changed files with 14 additions and 4 deletions
|
@ -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) -->
|
||||
![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 `<It>`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)
|
||||
![](./.github/assets/Error.png)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { defineConfig } = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
|
||||
fixturesFolder: "cypress/fixtures",
|
||||
snapshot: {
|
||||
// updateSnapshots: true,
|
||||
useFolders: true,
|
||||
|
|
|
@ -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 }))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"data": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue