-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathslack-skipped-tests.js
38 lines (32 loc) · 1.19 KB
/
slack-skipped-tests.js
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
/*---------------------------------------------------------------------------------------------
* Copyright (C) 2024 Posit Software, PBC. All rights reserved.
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/
const { execSync } = require('child_process');
const slackSkippedTests = (slackWebhookUrl) => {
try {
const skippedTests = execSync(
`grep -r --include \\*.test.ts -E "describe\\.skip|test\\.skip" test/e2e/tests | sed 's/\\.test\\.ts.*$/.test.ts/'`
).toString();
const slackMessage = {
attachments: [
{
mrkdwn_in: ['text'],
color: skippedTests === '' ? '#CCCCCC' : '#FF0000',
pretext: ':skipping:*Skipped Tests*',
text: skippedTests === '' ? 'There are no skipped tests. :tada:' : skippedTests,
},
],
};
console.log(skippedTests);
console.log(JSON.stringify(slackMessage, null, 2));
execSync(
`curl -X POST -H 'Content-type: application/json' --data '${JSON.stringify(
slackMessage
)}' ${slackWebhookUrl}`
);
} catch (error) {
console.error(`Error: ${error}`);
}
};
slackSkippedTests(process.argv[2]);