-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add batch support #9
Comments
One of the options is something like: const screenshot1 = await page.screenshot();
// do something
const screenshot2 = await page.screenshot();
// do something
const screenshot3 = await page.screenshot();
const screenshots = [{screenshot: screenshot1, key: 'first screenshot'}, ...];
await expect(screenshots).toMatchScreenshot(); Then we can just This will also solve #4 |
import { eyes } from 'match-screenshot';
describe('suite', () => {
it('test', async function () {
const shots = new eyes.Shots();
shots.add(await page.screenshot(), 'first one', { version: '3.0.0' });
shots.add(await page.screenshot(), 'second one');
shots.add(await page.screenshot(), 'third');
await shots.match(this.getFullTitle(), { version: '2.0.0' });
});
it('using matcher', async () => {
const shots = new eyes.Shots();
shots.add(await page.screenshot(), 'first one', { version: '3.0.0' });
shots.add(await page.screenshot(), 'second one');
shots.add(await page.screenshot(), 'third');
await expect(shots).toMatchScreenshot(this.getFullTitle(), { version: '2.0.0' });
});
}); ??? |
i am not really sure regarding the test title. |
|
|
hmmm, I think so... do you have a different way to do so? |
Something similar to this one: |
Ok, i would suggest to do like this: expect([...] || {}).toMatchEyes(testName, optionalParams); expect(screenshots).toMatchEyes(this.getFullTitle());
expect(screenshots).toMatchEyes('test title');
expect(screenshots).toMatchEyes('test title', { version: '2.0.0' }); |
In such way eyes test title would be optional. const {Assertion} = require('chai');
const {toMatchScreenshot} = require('match-screenshot/chai');
const {withMochaSpecTitle} = require('match-screenshot/mocha');
const {withCustomSpecTitle} = require('match-screenshot/custom');
Assertion.addMethod('toMatchScreenshot', withMochaSpecTitle(toMatchScreenshot));
Assertion.addMethod('toMatchScreenshot', withCustomSpecTitle(toMatchScreenshot, () => Math.random()));
expect(screenshots).toMatchEyes(); // will take a default one
expect(screenshots).toMatchEyes('my nice test'); // will override a default one |
const screenshots = [{
screenshot: screenshot1,
windowName: 'first screen'
}, {
screenshot: screenshot2,
windowName: 'second screen'
}]; screenshots definition looks complex IMHO Maybe having an object would be much easier? expect({
'first screen': screenshot1,
'second screen' screenshot2
}).toMatchEyes(); |
You put 👍 for everything :) Regarding matcher API I am ok fine. Can implement. |
Sorry, was too tired and watched from mobile. imo:
LMK if I can help with that |
Inside e2e tests i would really want to make multiple screenshots and checks per
it/test
The text was updated successfully, but these errors were encountered: