Ability to change path by overriding task#179
Ability to change path by overriding task#179mikstime wants to merge 8 commits intoFRSOURCE:mainfrom
Conversation
src/commands.ts
Outdated
| log: false, | ||
| }) | ||
| .then(() => cy.task(TASK.processImgPath, { path: imgPath }).then(newImgPath => imgPath = newImgPath)) | ||
| .then(() => imgPath); |
There was a problem hiding this comment.
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.