Skip to content

Commit

Permalink
Avoid logging HTTP request in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Dec 23, 2021
1 parent ea36ca9 commit e1f3c48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/api.ts
Expand Up @@ -9,12 +9,16 @@ const GitHub = Octokit.plugin(restEndpointMethods, requestLog).defaults({

export type API = InstanceType<typeof GitHub>

export default function (token: string, options?: { fetch?: any }): API {
export default function (
token: string,
options?: { logRequests?: boolean; fetch?: any }
): API {
return new GitHub({
request: { fetch: options && options.fetch },
auth: `token ${token}`,
log: {
info(msg: string) {
if (options?.logRequests === false) return
return console.info(msg)
},
debug(msg: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/main-test.ts
Expand Up @@ -54,7 +54,7 @@ test('prepareEdit()', async (t) => {
}
throw url
}
const apiClient = api('ATOKEN', { fetch: stubbedFetch })
const apiClient = api('ATOKEN', { fetch: stubbedFetch, logRequests: false })

const opts = await prepareEdit(ctx, apiClient, apiClient)
t.is(opts.owner, 'Homebrew')
Expand Down

0 comments on commit e1f3c48

Please sign in to comment.