Repository navigation
Expand file tree
/
Copy pathsendTestResults.js
More file actions
80 lines (53 loc) · 1.52 KB
/
Copy pathsendTestResults.js
File metadata and controls
80 lines (53 loc) · 1.52 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const { execSync } = require('child_process');
console.log('\nTestler çalıştırılıyor...\n');
try {
execSync('jest --json --outputFile ./resultz.json -c ./jest.config.js --forceExit', {
stdio: 'inherit',
cwd: __dirname,
});
} catch (_) {
// testler fail olsa da devam et
}
const user = require("./user.json");
const results = require("./resultz.json");
(async () => {
const userId = user.user_id;
const taskId = 78;
const { numPassedTests, numTotalTests } = results;
const score = (numPassedTests / numTotalTests).toFixed(2);
const payload = { score, taskId, userId };
if (userId == 1234) {
console.error(`
!!!! DİKKAT: !!!!
User id'nizi user.json dosyasına ekleyin!
User id'nizi nextgen'de projeye tıkladığınızda görebilirsiniz.
`);
return;
}
try {
const response = await fetch(
"https://backend.api.workintech.com.tr/nextgen/taskLog/saveJavaTasks",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
}
);
if (!response.ok) {
console.error(`
!!! Houston bir hata aldık :(
!!! Status Code: ${response.status} !!!
Slack #teknik-yardım kanalından destek isteyebilirsin.
`);
}
if (response.ok) {
console.log(`
Bu projedeki güncel score'unuz: %${Math.ceil(score * 100)}
Başarıyla kaydedildi.
Nextgen'i refresh yaparak kontrol edebilirsiniz.
`);
}
} catch (error) {
console.error("\n!!! Sonuçları yollarken hata oluştu: ", error);
}
})();