-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to change path by overriding task #179
base: main
Are you sure you want to change the base?
Conversation
src/commands.ts
Outdated
@@ -162,6 +162,7 @@ Cypress.Commands.add( | |||
}, | |||
log: false, | |||
}) | |||
.then(() => cy.task(TASK.processImgPath, { path: imgPath }).then(newImgPath => imgPath = newImgPath)) | |||
.then(() => imgPath); |
There was a problem hiding this comment.
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
Hey @mikstime, thank you for this PR! |
Update task.hook.ts
fix: Linter and Typescript
I didn't want to change plugin's behaviour but wanted to integrate this plugin with mochawesome reporter. By overriding after:screenshot hook and changing imgPath it is possible to do so. const pathMapping = {};
const on2 = (action, handler) => {
if (action === 'after:screenshot') {
const newHandler = async props => {
const originalPath = props.path;
const newProps = await handler(props);
if (newProps) {
await fs.copyFile(newProps.path, originalPath);
pathMapping[originalPath] = newProps.path;
}
};
on(action, newHandler);
} else if (action === 'task') {
handler[TASK.processImgPath] = ({ path }) => pathMapping[path];
on(action, handler);
} else {
on(action, handler);
}
};
initPlugin(on2, config); It is useful to know that by changing code above it is possible to replace image in the report file e.g combine screenshot and diff file together. I might or might not publish this as a separate package in the near future |
Hey! I'm just wondering - currently there is a possibility to leave the images in the original screenshots directory by using But either way - this change make sense, I'll approve it and merge soon. I'm also thinking about providing a mochawesome recipe: |
It's been a while since I finished with this problem. I believe that is exactly what it does. I've tried implementing a proper solution for this problem and ended up rewriting plenty of code since there was a lot of unclear logic related to absolute/relative paths. Currently i can't share my solution.
Sorry, short on time currently. Won't try this one on my own. |
3ea7824
to
b215cc3
Compare
No description provided.