Skip to content
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

fix: generates local report with viewports now #52

Merged
merged 1 commit into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion e2eTests/generateHtmlReport/generateReportConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scenarios": [
{
"url": "http:/google.com/",
"label": "homepage"
"label": "homepage",
"viewports": [{"height": 2400, "width": 1024, "label": "large"}]
}]
}

38 changes: 20 additions & 18 deletions src/generateReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@ const createReportData = config => {
const report = [];

for (let i = 0; i < config.scenarios.length; i++) {
const imageName = `${config.scenarios[i].label}.png`;
const baselinePath = path.resolve(`${config.baseline}/${imageName}`);
const latestPath = path.resolve(`${config.latest}/${imageName}`);
const generatedDiffsPath = path.resolve(
`${config.generatedDiffs}/${imageName}`
);
const scenario = config.scenarios[i];
scenario.viewports.forEach(viewport => {
const name = `${scenario.label}-${viewport.label}`;
const imageName = `${name}.png`;

if (fs.existsSync(generatedDiffsPath)) {
logger.info(
'generate-report',
`found diff for ${config.scenarios[i].label}`
const baselinePath = path.resolve(`${config.baseline}/${imageName}`);
const latestPath = path.resolve(`${config.latest}/${imageName}`);
const generatedDiffsPath = path.resolve(
`${config.generatedDiffs}/${imageName}`
);
const scenarioData = {
label: config.scenarios[i].label,
baseline: baselinePath,
latest: latestPath,
generatedDiff: generatedDiffsPath
};

report.push(scenarioData);
}
if (fs.existsSync(generatedDiffsPath)) {
logger.info('generate-report', `found diff for ${name}`);
const scenarioData = {
label: name,
baseline: baselinePath,
latest: latestPath,
generatedDiff: generatedDiffsPath
};

report.push(scenarioData);
}
});
}
return report;
};
Expand Down
2 changes: 1 addition & 1 deletion src/snapshotter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('The snapshotter', () => {
expect(seleniumMock).toBeCalledWith(mockSnapshot.driver);
});

it.only('Throws an error if incorrect script file is provided', async () => {
it('Throws an error if incorrect script file is provided', async () => {
const config = {
gridUrl: 'https://lol.com',
url: 'http://cps-render-ci.elb.tnl-dev.ntch.co.uk/',
Expand Down