Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 650b0aa

Browse files
authored
Merge pull request #106 from heartexlabs/tests/async-fail
* Yield e2e output as artifact on fail * Add example of catching errors in async codecept scripts * Fix non-stable test with polygons
2 parents 15357ca + 018f66a commit 650b0aa

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
- run: npm run test:e2e:headless
4343
if: github.event_name == 'push'
4444

45+
- uses: actions/upload-artifact@master
46+
if: ${{ failure() }}
47+
with:
48+
name: e2e output
49+
path: e2e/output/
50+
4551
# upload this build as artifact to current Action
4652
- uses: actions/upload-artifact@master
4753
with:

e2e/tests/helpers.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,29 @@ const clickMultipleKonva = async (points, done) => {
139139
* @param {function} done
140140
*/
141141
const polygonKonva = async (points, done) => {
142-
const delay = () => new Promise(resolve => setTimeout(resolve, 10));
143-
const stage = window.Konva.stages[0];
144-
const firstCoords = points[0];
145-
for (let point of points) {
146-
stage.fire("click", { evt: { offsetX: point[0], offsetY: point[1] } });
142+
try {
143+
const delay = () => new Promise(resolve => setTimeout(resolve, 10));
144+
const stage = window.Konva.stages[0];
145+
for (let point of points) {
146+
stage.fire("click", { evt: { offsetX: point[0], offsetY: point[1] } });
147+
await delay();
148+
}
149+
150+
// this works in 50% runs for no reason; maybe some async lazy calculations
151+
// const firstPoint = stage.getIntersection({ x, y });
152+
153+
// Circles (polygon points) redraw every new click so we can find it only after last click
154+
const lastPoint = stage.find("Circle").slice(-1)[0];
155+
const firstPoint = lastPoint.parent.find("Circle")[0];
156+
// for closing the Polygon we should place cursor over the first point
157+
firstPoint.fire("mouseover");
147158
await delay();
159+
// and only after that we can click on it
160+
firstPoint.fire("click");
161+
done();
162+
} catch (e) {
163+
done(String(e));
148164
}
149-
150-
// for closing the Polygon we should place cursor over the first point
151-
const firstPoint = stage.getIntersection({ x: firstCoords[0], y: firstCoords[1] });
152-
firstPoint.fire("mouseover");
153-
await delay();
154-
// and only after that we can click on it
155-
firstPoint.fire("click");
156-
done();
157165
};
158166

159167
/**

e2e/tests/image.shapes.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ Scenario("Simple shapes on Image", async function(I) {
143143

144144
for (let region of shape.regions) {
145145
// draw the shape using corresponding helper and params
146-
await I.executeAsyncScript(shape.action, ...region.params);
146+
const err = await I.executeAsyncScript(shape.action, ...region.params);
147+
if (err) throw new Error(err);
147148
}
148149

149150
const result = await I.executeScript(serialize);

0 commit comments

Comments
 (0)