0

Retrieve test suites belonging to a repositorys test results

by
Published Oct 17, 2025

Retrieves test suites belonging to a repository's test results. It accepts a list of test suites as a query parameter to specify individual test suites.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve test suites belonging to a repositorys test results
4
 * Retrieves test suites belonging to a repository's test results.
5
It accepts a list of test suites as a query parameter to specify individual test suites.
6
 */
7
export async function main(
8
	auth: RT.Sentry,
9
	owner: string,
10
	repository: string,
11
	term?: string | undefined
12
) {
13
	const url = new URL(
14
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/prevent/owner/${owner}/repository/${repository}/test-suites/`
15
	)
16
	for (const [k, v] of [['term', term]]) {
17
		if (v !== undefined && v !== '') {
18
			url.searchParams.append(k, v)
19
		}
20
	}
21
	const response = await fetch(url, {
22
		method: 'GET',
23
		headers: {
24
			Authorization: 'Bearer ' + auth.token
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34