-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcypress.config.ts
62 lines (54 loc) · 1.75 KB
/
cypress.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { PublishCommand, SNSClient } from "@aws-sdk/client-sns";
import { defineConfig } from "cypress";
export default defineConfig({
video: false,
projectId: "f6ssqp",
e2e: {
baseUrl: "https://www.dolthub.com",
specPattern: "cypress/e2e/dolthub/**/*.{js,jsx,ts,tsx}",
setupNodeEvents(on, config) {
on("task", {
log(message) {
console.log(message);
return null;
},
});
on("after:run", results => {
if (results) {
// results will be undefined in interactive mode
const alertOnFailure = !!process.env.ALERT_ON_FAILURE;
if (alertOnFailure) {
const adjustedTotal = results.totalTests - results.totalSkipped;
const percentFailed = Math.floor(
100 * (results.totalFailed / adjustedTotal),
);
if (percentFailed >= 25) {
const region = process.env.AWS_REGION;
const topicArn = process.env.SNS_TOPIC_ARN;
const params = {
Message: "dolthub_degraded_cypress_1",
TopicArn: topicArn,
};
const snsClient = new SNSClient({ region: region });
const run = async () => {
try {
const data = await snsClient.send(new PublishCommand(params));
console.log(
"Successfully alarmed by sending SNS message.",
data,
);
return data; // For unit tests.
} catch (err) {
console.log("Error", err.stack);
}
};
run();
}
}
}
});
},
},
viewportWidth: 1440,
viewportHeight: 900,
});