Skip to content

Commit abc6f35

Browse files
committed
test: add retry to uploadManifestFiles tests to handle flaky CI behavior
Add retry: 2 configuration to both uploadManifestFiles tests to handle intermittent failures seen in Ubuntu CI while passing on Windows and macOS. The flaky behavior suggests environment-specific timing issues with nock mock matching.
1 parent f3ecee7 commit abc6f35

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

test/socket-sdk-upload-simple.test.mts

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,52 @@ describe('SocketSdk - Upload Manifest Coverage', () => {
3636
})
3737

3838
describe('uploadManifestFiles', () => {
39-
it('should successfully execute upload manifest files method', async () => {
40-
nock('https://api.socket.dev')
41-
.post('/v0/orgs/test-org/upload-manifest-files')
42-
.reply(200, {
43-
tarHash: 'abc123def456',
44-
unmatchedFiles: [],
45-
})
39+
it(
40+
'should successfully execute upload manifest files method',
41+
{ retry: 2 },
42+
async () => {
43+
nock('https://api.socket.dev')
44+
.post('/v0/orgs/test-org/upload-manifest-files')
45+
.reply(200, {
46+
tarHash: 'abc123def456',
47+
unmatchedFiles: [],
48+
})
4649

47-
const result = await sdk.uploadManifestFiles('test-org', [
48-
packageJsonPath,
49-
])
50+
const result = await sdk.uploadManifestFiles('test-org', [
51+
packageJsonPath,
52+
])
5053

51-
expect(result.success).toBe(true)
52-
expect(result.status).toBe(200)
53-
if (result.success) {
54-
expect(result.data.tarHash).toBe('abc123def456')
55-
expect(result.data.unmatchedFiles).toEqual([])
56-
}
57-
})
54+
expect(result.success).toBe(true)
55+
expect(result.status).toBe(200)
56+
if (result.success) {
57+
expect(result.data.tarHash).toBe('abc123def456')
58+
expect(result.data.unmatchedFiles).toEqual([])
59+
}
60+
},
61+
)
5862

59-
it('should handle errors in uploadManifestFiles', async () => {
60-
nock('https://api.socket.dev')
61-
.post('/v0/orgs/test-org/upload-manifest-files')
62-
.reply(400, {
63-
error: {
64-
message: 'Invalid manifest files',
65-
},
66-
})
63+
it(
64+
'should handle errors in uploadManifestFiles',
65+
{ retry: 2 },
66+
async () => {
67+
nock('https://api.socket.dev')
68+
.post('/v0/orgs/test-org/upload-manifest-files')
69+
.reply(400, {
70+
error: {
71+
message: 'Invalid manifest files',
72+
},
73+
})
6774

68-
const result = await sdk.uploadManifestFiles('test-org', [
69-
packageJsonPath,
70-
])
75+
const result = await sdk.uploadManifestFiles('test-org', [
76+
packageJsonPath,
77+
])
7178

72-
expect(result.success).toBe(false)
73-
if (!result.success) {
74-
expect(result.status).toBe(400)
75-
expect(result.error).toContain('Invalid manifest files')
76-
}
77-
})
79+
expect(result.success).toBe(false)
80+
if (!result.success) {
81+
expect(result.status).toBe(400)
82+
expect(result.error).toContain('Invalid manifest files')
83+
}
84+
},
85+
)
7886
})
7987
})

0 commit comments

Comments
 (0)