Skip to content

Commit 0af7ee2

Browse files
committed
test: capture all screenshot
1 parent a4f3785 commit 0af7ee2

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class Utils:
2020
@staticmethod
21-
async def assert_screenshot(page, baseline_image, result_directory, threshold=0.1):
21+
async def compare_screenshot(page, baseline_image, result_directory, threshold=0.1):
2222
test_image = result_directory / baseline_image.name
2323
await page.screenshot(path=test_image)
2424

@@ -29,7 +29,7 @@ async def assert_screenshot(page, baseline_image, result_directory, threshold=0.
2929
file_diff = (test_image.parent / test_image.stem).with_suffix(".diff.png")
3030
mismatch = pixelmatch(img_ref, img_test, img_diff, threshold=threshold)
3131
img_diff.save(file_diff)
32-
assert mismatch < threshold
32+
return mismatch < threshold
3333

3434

3535
def create_vtk_pipeline():

tests/test_cone.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async def test_cone(ConeApp, utils, config):
3434
task = app.server.start(exec_mode="task", port=0)
3535
await app.server.ready
3636
RESULT_BASE = Path(__file__).with_name("results") / "cone" / conf_key
37+
valid_image_comparisons = []
3738

3839
async with async_playwright() as p:
3940
browser = await p.chromium.launch(headless=True)
@@ -42,20 +43,38 @@ async def test_cone(ConeApp, utils, config):
4243

4344
await page.goto(f"http://localhost:{app.server.port}/")
4445
await expect(page.locator(".readyCount")).to_have_text("1")
45-
await utils.assert_screenshot(page, BASELINES[0], RESULT_BASE, threshold=0.1)
46+
valid_image_comparisons.append(
47+
await utils.compare_screenshot(
48+
page, BASELINES[0], RESULT_BASE, threshold=0.1
49+
)
50+
)
4651

4752
app.resolution = 60
4853
await expect(page.locator(".readyCount")).to_have_text("2")
49-
await utils.assert_screenshot(page, BASELINES[1], RESULT_BASE, threshold=0.1)
54+
valid_image_comparisons.append(
55+
await utils.compare_screenshot(
56+
page, BASELINES[1], RESULT_BASE, threshold=0.1
57+
)
58+
)
5059

5160
app.mounted = False
5261
app.resolution = 4
53-
await utils.assert_screenshot(page, BASELINES[2], RESULT_BASE, threshold=0.1)
62+
valid_image_comparisons.append(
63+
await utils.compare_screenshot(
64+
page, BASELINES[2], RESULT_BASE, threshold=0.1
65+
)
66+
)
5467

5568
app.mounted = True
5669
await asyncio.sleep(0.1) # Debounced resize needs complete
5770
await expect(page.locator(".readyCount")).to_have_text("3")
58-
await utils.assert_screenshot(page, BASELINES[3], RESULT_BASE, threshold=0.1)
71+
valid_image_comparisons.append(
72+
await utils.compare_screenshot(
73+
page, BASELINES[3], RESULT_BASE, threshold=0.1
74+
)
75+
)
76+
77+
assert all(valid_image_comparisons), "Some images don't match"
5978

6079
# Clean up resource
6180
await browser.close()

0 commit comments

Comments
 (0)