mirror of
https://github.com/datashard/snapshot.git
synced 2024-11-22 06:02:29 +00:00
fixtures now read and write from cypress
This commit is contained in:
parent
930662045c
commit
b4f841d878
2 changed files with 4 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
const { defineConfig } = require("cypress");
|
const { defineConfig } = require("cypress");
|
||||||
|
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
fixturesFolder: "cypress/fixtures",
|
// fixturesFolder: "cypress/fixtures",
|
||||||
snapshot: {
|
snapshot: {
|
||||||
// updateSnapshots: true,
|
// updateSnapshots: true,
|
||||||
useFolders: true,
|
useFolders: true,
|
||||||
|
|
|
@ -22,12 +22,9 @@ const parseTextToJSON = (text) => text.replace(/\| [✅➖➕⭕]/g, "").trim().
|
||||||
const store_snapshot = (props = { value, name, raiser }) => {
|
const store_snapshot = (props = { value, name, raiser }) => {
|
||||||
if (Cypress.env().updateSnapshots || Cypress.config('snapshot').updateSnapshots) {
|
if (Cypress.env().updateSnapshots || Cypress.config('snapshot').updateSnapshots) {
|
||||||
cy.SNAPSHOT_prettyprint({ title: "INFO", type: "info", message: "Saving Snapshot" })
|
cy.SNAPSHOT_prettyprint({ title: "INFO", type: "info", message: "Saving Snapshot" })
|
||||||
cy.writeFile(`${Cypress.env().fixturesFolder}/${props.name}.json`, JSON.stringify(props.value, null, 2))
|
cy.writeFile(path.join(Cypress.config().fixturesFolder,`${props.name}.json`), JSON.stringify(props.value, null, 2))
|
||||||
} else {
|
} else {
|
||||||
// TODO: Figure out how to replace the fixture folder name if people move it
|
cy.fixture(props.name).then(content => props.raiser({ value: props.value, expected: content }))
|
||||||
// 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 }))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,9 +112,7 @@ module.exports = (value, stepName, options = { json: true }) => {
|
||||||
options.asFolder = Cypress.config('snapshot').useFolders || false
|
options.asFolder = Cypress.config('snapshot').useFolders || false
|
||||||
|
|
||||||
set_snapshot({
|
set_snapshot({
|
||||||
snapshotName: path.join(
|
snapshotName: `/${get_snapshot_name(options.asFolder, stepName)}`,
|
||||||
options.snapshotPath || Cypress.config('snapshot').snapshotPath || 'cypress/fixtures/snapshots',
|
|
||||||
`/${get_snapshot_name(options.asFolder, stepName)}`),
|
|
||||||
serialized,
|
serialized,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue