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

Commit 0275c28

Browse files
committed
[cypress] Avoid mockBackend singleton in integration tests
1 parent 0b2224d commit 0275c28

14 files changed

+74
-19
lines changed

packages/cypress-plugin/test/integration/src/basic-matrix.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { QuarantineMode } from "@unflakable/plugins-common";
1010
import { afterEach, beforeEach } from "@jest/globals";
1111
import * as fs from "fs/promises";
1212

13-
integrationTestSuite(() => {
13+
integrationTestSuite((mockBackend) => {
1414
Object.entries(TEST_PROJECTS).forEach(([projectName, project]) => {
1515
describe(
1616
projectName === "integration-input"
@@ -84,6 +84,7 @@ integrationTestSuite(() => {
8484
}
8585
: defaultSummaryTotals,
8686
},
87+
mockBackend,
8788
done
8889
)
8990
);

packages/cypress-plugin/test/integration/src/basic.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "./test-wrappers";
88
import { QuarantineMode } from "@unflakable/plugins-common";
99

10-
integrationTestSuite(() => {
10+
integrationTestSuite((mockBackend) => {
1111
it("quarantine flaky test", (done) =>
1212
integrationTest(
1313
{
@@ -21,6 +21,7 @@ integrationTestSuite(() => {
2121
numQuarantined: 5,
2222
},
2323
},
24+
mockBackend,
2425
done
2526
));
2627

@@ -43,6 +44,7 @@ integrationTestSuite(() => {
4344
numTests: 19,
4445
},
4546
},
47+
mockBackend,
4648
done
4749
));
4850

@@ -76,6 +78,7 @@ integrationTestSuite(() => {
7678
numTests: 19,
7779
},
7880
},
81+
mockBackend,
7982
done
8083
)
8184
);

packages/cypress-plugin/test/integration/src/config.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { integrationTestSuite, integrationTest } from "./test-wrappers";
44

5-
integrationTestSuite(() => {
5+
integrationTestSuite((mockBackend) => {
66
it("set test suite ID via config", (done) =>
77
integrationTest(
88
{
@@ -16,6 +16,7 @@ integrationTestSuite(() => {
1616
expectedSuiteId: "MOCK_SUITE_ID_CONFIG",
1717
},
1818
},
19+
mockBackend,
1920
done
2021
));
2122

@@ -33,6 +34,7 @@ integrationTestSuite(() => {
3334
expectedSuiteId: "MOCK_SUITE_ID_ENV",
3435
},
3536
},
37+
mockBackend,
3638
done
3739
));
3840

@@ -47,6 +49,7 @@ integrationTestSuite(() => {
4749
expectedSuiteId: "MOCK_SUITE_ID_CLI",
4850
},
4951
},
52+
mockBackend,
5053
done
5154
));
5255

@@ -65,6 +68,7 @@ integrationTestSuite(() => {
6568
expectedSuiteId: "MOCK_SUITE_ID_CLI",
6669
},
6770
},
71+
mockBackend,
6872
done
6973
));
7074
});

packages/cypress-plugin/test/integration/src/disable-plugin.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
integrationTestSuite,
77
} from "./test-wrappers";
88

9-
integrationTestSuite(() => {
9+
integrationTestSuite((mockBackend) => {
1010
const expectedExitCodeWithPluginDisabled = 11;
1111
const summaryTotalsWithPluginDisabled = {
1212
...defaultSummaryTotals,
@@ -27,6 +27,7 @@ integrationTestSuite(() => {
2727
expectedExitCode: expectedExitCodeWithPluginDisabled,
2828
summaryTotals: summaryTotalsWithPluginDisabled,
2929
},
30+
mockBackend,
3031
done
3132
));
3233

@@ -42,6 +43,7 @@ integrationTestSuite(() => {
4243
expectedExitCode: expectedExitCodeWithPluginDisabled,
4344
summaryTotals: summaryTotalsWithPluginDisabled,
4445
},
46+
mockBackend,
4547
done
4648
));
4749

@@ -57,6 +59,7 @@ integrationTestSuite(() => {
5759
},
5860
},
5961
},
62+
mockBackend,
6063
done
6164
));
6265
});

packages/cypress-plugin/test/integration/src/disable-upload.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { integrationTest, integrationTestSuite } from "./test-wrappers";
44

5-
integrationTestSuite(() => {
5+
integrationTestSuite((mockBackend) => {
66
it("disable upload via config", (done) =>
77
integrationTest(
88
{
@@ -13,6 +13,7 @@ integrationTestSuite(() => {
1313
expectResultsToBeUploaded: false,
1414
},
1515
},
16+
mockBackend,
1617
done
1718
));
1819

@@ -26,6 +27,7 @@ integrationTestSuite(() => {
2627
expectResultsToBeUploaded: false,
2728
},
2829
},
30+
mockBackend,
2931
done
3032
));
3133

@@ -41,6 +43,7 @@ integrationTestSuite(() => {
4143
expectResultsToBeUploaded: false,
4244
},
4345
},
46+
mockBackend,
4447
done
4548
));
4649

@@ -56,6 +59,7 @@ integrationTestSuite(() => {
5659
},
5760
},
5861
},
62+
mockBackend,
5963
done
6064
));
6165
});

packages/cypress-plugin/test/integration/src/git.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { integrationTest, integrationTestSuite } from "./test-wrappers";
44
import path from "path";
55

6-
integrationTestSuite(() => {
6+
integrationTestSuite((mockBackend) => {
77
it("no git repo", (done) =>
88
integrationTest(
99
{
@@ -17,6 +17,7 @@ integrationTestSuite(() => {
1717
},
1818
},
1919
},
20+
mockBackend,
2021
done
2122
));
2223

@@ -47,6 +48,7 @@ integrationTestSuite(() => {
4748
expectedBranch: "pull/MOCK_PR_NUMBER/merge",
4849
},
4950
},
51+
mockBackend,
5052
done
5153
));
5254

@@ -62,6 +64,7 @@ integrationTestSuite(() => {
6264
expectedCommit: "MOCK_COMMIT_ENV",
6365
},
6466
},
67+
mockBackend,
6568
done
6669
));
6770

@@ -84,6 +87,7 @@ integrationTestSuite(() => {
8487
expectedCommit: "MOCK_COMMIT_CLI",
8588
},
8689
},
90+
mockBackend,
8791
done
8892
));
8993

@@ -100,6 +104,7 @@ integrationTestSuite(() => {
100104
expectedRepoRelativePathPrefix: "",
101105
},
102106
},
107+
mockBackend,
103108
done
104109
));
105110

@@ -114,6 +119,7 @@ integrationTestSuite(() => {
114119
expectedRepoRelativePathPrefix: "",
115120
},
116121
},
122+
mockBackend,
117123
done
118124
));
119125
});

packages/cypress-plugin/test/integration/src/hook-failures.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { integrationTest, integrationTestSuite } from "./test-wrappers";
44

5-
integrationTestSuite(() => {
5+
integrationTestSuite((mockBackend) => {
66
it("run should succeed when before() fails both tests are quarantined", (done) =>
77
integrationTest(
88
{
@@ -23,6 +23,7 @@ integrationTestSuite(() => {
2323
numTests: 2,
2424
},
2525
},
26+
mockBackend,
2627
done
2728
));
2829

@@ -48,6 +49,7 @@ integrationTestSuite(() => {
4849
numTests: 2,
4950
},
5051
},
52+
mockBackend,
5153
done
5254
));
5355

@@ -73,6 +75,7 @@ integrationTestSuite(() => {
7375
numTests: 2,
7476
},
7577
},
78+
mockBackend,
7679
done
7780
));
7881

@@ -95,6 +98,7 @@ integrationTestSuite(() => {
9598
numTests: 2,
9699
},
97100
},
101+
mockBackend,
98102
done
99103
));
100104

@@ -118,6 +122,7 @@ integrationTestSuite(() => {
118122
numTests: 2,
119123
},
120124
},
125+
mockBackend,
121126
done
122127
));
123128

@@ -141,6 +146,7 @@ integrationTestSuite(() => {
141146
numTests: 2,
142147
},
143148
},
149+
mockBackend,
144150
done
145151
));
146152

@@ -164,6 +170,7 @@ integrationTestSuite(() => {
164170
numTests: 2,
165171
},
166172
},
173+
mockBackend,
167174
done
168175
));
169176

@@ -188,6 +195,7 @@ integrationTestSuite(() => {
188195
numTests: 2,
189196
},
190197
},
198+
mockBackend,
191199
done
192200
));
193201

@@ -212,6 +220,7 @@ integrationTestSuite(() => {
212220
numTests: 2,
213221
},
214222
},
223+
mockBackend,
215224
done
216225
));
217226

@@ -238,6 +247,7 @@ integrationTestSuite(() => {
238247
numTests: 2,
239248
},
240249
},
250+
mockBackend,
241251
done
242252
));
243253

@@ -262,6 +272,7 @@ integrationTestSuite(() => {
262272
numTests: 2,
263273
},
264274
},
275+
mockBackend,
265276
done
266277
));
267278

@@ -288,6 +299,7 @@ integrationTestSuite(() => {
288299
numTests: 2,
289300
},
290301
},
302+
mockBackend,
291303
done
292304
));
293305

@@ -310,6 +322,7 @@ integrationTestSuite(() => {
310322
numTests: 2,
311323
},
312324
},
325+
mockBackend,
313326
done
314327
));
315328

@@ -334,6 +347,7 @@ integrationTestSuite(() => {
334347
numTests: 2,
335348
},
336349
},
350+
mockBackend,
337351
done
338352
));
339353

@@ -358,6 +372,7 @@ integrationTestSuite(() => {
358372
numTests: 2,
359373
},
360374
},
375+
mockBackend,
361376
done
362377
));
363378
});

packages/cypress-plugin/test/integration/src/long-names.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "./test-wrappers";
88
import { QuarantineMode } from "@unflakable/plugins-common";
99

10-
integrationTestSuite(() => {
10+
integrationTestSuite((mockBackend) => {
1111
it.each(["ignore_failures", "skip_tests"] as QuarantineMode[])(
1212
"test names longer than 4096 chars should be truncated w/ quarantineMode = %s",
1313
(quarantineMode, done) =>
@@ -35,6 +35,7 @@ integrationTestSuite(() => {
3535
}
3636
: defaultSummaryTotals,
3737
},
38+
mockBackend,
3839
done
3940
)
4041
);
@@ -66,6 +67,7 @@ integrationTestSuite(() => {
6667
numQuarantined: quarantineMode === "skip_tests" ? 6 : 5,
6768
},
6869
},
70+
mockBackend,
6971
done
7072
)
7173
);

packages/cypress-plugin/test/integration/src/no-quarantine.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
integrationTestSuite,
77
} from "./test-wrappers";
88

9-
integrationTestSuite(() => {
9+
integrationTestSuite((mockBackend) => {
1010
it.each(["CLI", "config"] as ("CLI" | "config")[])(
1111
"set quarantineMode to no_quarantine via %s",
1212
(mode, done) =>
@@ -35,6 +35,7 @@ integrationTestSuite(() => {
3535
numFlaky: 3,
3636
},
3737
},
38+
mockBackend,
3839
done
3940
)
4041
);

0 commit comments

Comments
 (0)