mirror of
https://github.com/datashard/snapshot.git
synced 2024-11-24 06:42:29 +00:00
add ability to pass custom names
This commit is contained in:
parent
faeb258eb9
commit
4736fb269e
1 changed files with 6 additions and 5 deletions
|
@ -38,8 +38,9 @@ const store_snapshot = (store, props = { value, name, path, raiser }) => {
|
||||||
.join("_")
|
.join("_")
|
||||||
.replace(/ /gi, "-")
|
.replace(/ /gi, "-")
|
||||||
.replace(/\//gi, "-");
|
.replace(/\//gi, "-");
|
||||||
const snapshotPath = Cypress.config("snapshot").snapshotPath || "cypress/snapshots"
|
const snapshotPath = props.path || Cypress.config("snapshot").snapshotPath || "cypress/snapshots"
|
||||||
const expectedPath = path.join(snapshotPath, `${fileName}.json`);
|
// console.log(snapshotPath)
|
||||||
|
const expectedPath = path.join(snapshotPath, `${fileName}.json`);
|
||||||
// console.log("\x1b[31m%s\x1b[30m", "file: path", expectedPath);
|
// console.log("\x1b[31m%s\x1b[30m", "file: path", expectedPath);
|
||||||
cy.task("readFileMaybe", expectedPath).then((exist) => {
|
cy.task("readFileMaybe", expectedPath).then((exist) => {
|
||||||
// console.log("\x1b[35m%s\x1b[30m", "file: exists", exist);
|
// console.log("\x1b[35m%s\x1b[30m", "file: exists", exist);
|
||||||
|
@ -105,13 +106,13 @@ const get_snapshot_name = (test, custom_name) => {
|
||||||
return names;
|
return names;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (value, step, { humanName, snapshotPath, json } = {}) => {
|
module.exports = (value, step, { snapshotName, snapshotPath, json } = {}) => {
|
||||||
const snapshotName = get_snapshot_name(Cypress.currentTest, humanName || step);
|
const name = get_snapshot_name(Cypress.currentTest, snapshotName || step);
|
||||||
const serializer = pickSerializer(json, value);
|
const serializer = pickSerializer(json, value);
|
||||||
const serialized = serializer(value);
|
const serialized = serializer(value);
|
||||||
const store = newStore(serialized || {});
|
const store = newStore(serialized || {});
|
||||||
set_snapshot(store, {
|
set_snapshot(store, {
|
||||||
snapshotName,
|
snapshotName: name,
|
||||||
snapshotPath,
|
snapshotPath,
|
||||||
serialized,
|
serialized,
|
||||||
value,
|
value,
|
||||||
|
|
Loading…
Reference in a new issue