//native
type Circleci = {
token: string
}
/**
* Get flaky tests for a project
* Get a list of flaky tests for a given project. Flaky tests are branch agnostic.
A flaky test is a test that passed and failed in the same commit.
*/
export async function main(auth: Circleci, project_slug: string) {
const url = new URL(`https://circleci.com/api/v2/insights/${project_slug}/flaky-tests`)
const response = await fetch(url, {
method: 'GET',
headers: {
'Circle-Token': auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago