Skip to content

Commit 70f828f

Browse files
committed
feat: add queue flushing in after block
stop shipping esm or ts files
1 parent 0acd10e commit 70f828f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"sideEffects": false,
88
"license": "MIT",
99
"scripts": {
10-
"build": "del-cli dist && microbundle src/{constants,plugins,support}.ts -f cjs,esm",
10+
"build": "del-cli dist && microbundle src/{constants,plugins,support}.ts -f cjs",
1111
"lint": "eslint '**/*.ts' --ignore-pattern '**/*.d.ts'",
1212
"lint:fix": "yarn lint --fix",
1313
"lint:ci": "yarn lint --max-warnings 0",
@@ -68,7 +68,6 @@
6868
"access": "public"
6969
},
7070
"files": [
71-
"src",
7271
"dist",
7372
"package.json",
7473
"README.md",

src/support.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import "./commands";
22
import { FILE_SUFFIX, LINK_PREFIX, OVERLAY_CLASS, TASK } from "./constants";
33

4+
function queueClear() {
5+
(cy as unknown as { queue: { clear: () => void } }).queue.clear();
6+
(cy as unknown as { state: (k: string, value: unknown) => void }).state(
7+
"index",
8+
0
9+
);
10+
}
11+
12+
function queueRun() {
13+
// needed to run a task outside of the test processing flow
14+
(cy as unknown as { queue: { run: () => void } }).queue.run();
15+
}
16+
417
function generateOverlayTemplate(
518
title: string,
619
imgNewBase64: string,
@@ -73,6 +86,7 @@ after(() => {
7386
const { title, imgPath } = JSON.parse(
7487
atob(e.currentTarget.getAttribute("href").substring(LINK_PREFIX.length))
7588
);
89+
queueClear();
7690

7791
cachedReadFile(imageCache, imgPath, "base64")
7892
.then((imgNew) =>
@@ -90,6 +104,7 @@ after(() => {
90104
)
91105
.then(([imgNewBase64, imgOldBase64, imgDiffBase64]) => {
92106
if (!top) return false;
107+
queueClear();
93108

94109
Cypress.$(
95110
generateOverlayTemplate(
@@ -112,11 +127,12 @@ after(() => {
112127
wrapper.remove()
113128
);
114129

115-
// needed to run a task outside of the test processing flow
116-
(cy as unknown as { queue: { run: () => void } }).queue.run();
130+
queueRun();
117131
});
118132
});
119133

134+
queueRun();
135+
120136
return false;
121137
}
122138
);

0 commit comments

Comments
 (0)