Skip to content

Ability to change path by overriding task #179

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Cypress.Commands.add(
},
log: false,
})
.then(() => cy.task(TASK.processImgPath, { path: imgPath }).then(newImgPath => imgPath = newImgPath))
.then(() => imgPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line won't be needed anymore

})
.then((imgPath) =>
Expand Down
3 changes: 3 additions & 0 deletions src/task.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ export const compareImagesTask = async (
export const doesFileExistTask = ({ path }: { path: string }) =>
fs.existsSync(path);

export const processImgPath = ({ path }) => path;

/* c8 ignore start */
export const initTaskHook = (config: Cypress.PluginConfigOptions) => ({
[TASK.getScreenshotPathInfo]: getScreenshotPathInfoTask,
[TASK.cleanupImages]: cleanupImagesTask.bind(undefined, config),
[TASK.doesFileExist]: doesFileExistTask,
[TASK.approveImage]: approveImageTask,
[TASK.compareImages]: compareImagesTask,
[TASK.processImgPath]: processImgPath,
});
/* c8 ignore stop */