-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Verify latest release
- I verified that the issue exists in the latest html-reporter release
Html-reporter version
11.0.2
Last html-reporter version that worked
none
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
-
Set up Playwright (
npm init playwright
) -
Add our reporter to the config:
reporter: [ ['html-reporter/playwright', { enabled: true, defaultView: 'failed', path: 'html-report', }], ],
-
Write a simple screenshot test:
test('get screen', async ({ page }) => { await page.goto('https://playwright.dev/'); await expect(page).toHaveScreenshot('landing-page.png'); });
-
Open the UI (
npx html-reporter gui --tool playwright
) and accept the screenshot after running the test -
Replace the reference screenshot with a corrupted one (you can take any file and change its extension to
.png
) -
Run the test, which will expectedly fail with the aforementioned error
Actual Behavior
When an invalid screenshot is used as a reference image in a Playwright screenshot test, running such a test causes the entire Playwright test run to crash with an Error: Empty file
error.
Full stack trace
Error: Empty file
at readFileSync (.../node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/index.js:77:19)
at imageSize (.../node_modules/.pnpm/image-size@1.1.1/node_modules/image-size/dist/index.js:112:23)
at getImageData (.../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/adapters/test-result/playwright.ts:152:47)
at Array.map (<anonymous>)
at .../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/adapters/test-result/playwright.ts:253:110
at Array.map (<anonymous>)
at PlaywrightTestResultAdapter.get imagesInfo [as imagesInfo] (.../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/adapters/test-result/playwright.ts:248:69)
at baseGet (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:3077:24)
at basePickBy (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:3823:21)
at basePick (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:3802:14)
at Function.<anonymous> (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:13628:36)
at apply (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:489:27)
at Function.pick (.../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:6627:16)
at copyAndUpdate (.../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/adapters/test-result/utils/index.ts:47:46)
at StaticReportBuilder.provideAttempt (.../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/report-builder/static.ts:93:44)
at StaticReportBuilder.addTestResult (.../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/lib/report-builder/static.ts:121:38)
at .../node_modules/.pnpm/html-reporter@10.18.7_playwright@1.46.1/node_modules/html-reporter/playwright.ts:75:39
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at run (.../node_modules/.pnpm/p-queue@5.0.0/node_modules/p-queue/index.js:211:14)
This behavior is already handled for testplane tests, but only occurs with Playwright.
Expected Behavior
The main code that needs to be modified is the adapter. In the imagesInfo
method, we need to add error handling for ErrorName.INVALID_REF_IMAGE
(an example can be found in the testplane adapter).
The error type can only be matched by the text when it fails: "could not decode image as PNG"
Definition of Done
- When an invalid screenshot is present in a test, other tests run correctly
- The report for the failed test shows an error about the invalid screenshot
Which Node.js version are you using?
22
Internal issue: https://nda.ya.ru/t/2rT1286B7JkvFj
Metadata
Metadata
Assignees
Labels
Type
Projects
Status