← Public packages
@kentcdodds/google
Google helpers for Gmail, Calendar, Drive, People, YouTube (including upload), and Analytics.
Files
// Test-only preload: resolves `kody:runtime` to an in-memory stub so modules that
// import it can run under plain Node. Tests set `globalThis.__kodyTestFetch` to a
// mocked fetch; `createAuthenticatedFetch(name)` returns it.
import { registerHooks } from 'node:module'
const stubSource = `
export async function createAuthenticatedFetch(name) {
const fetchImpl = globalThis.__kodyTestFetch
if (!fetchImpl) throw new Error('No mocked fetch for credential ' + name)
return (input, init) => fetchImpl(input, init, name)
}
export function packageStorage() {
const data = new Map()
return { async get(key) { return data.get(key) }, async set(key, value) { data.set(key, value) }, async delete(key) { data.delete(key) } }
}
export const kody = {}
`
const stubUrl = 'data:text/javascript,' + encodeURIComponent(stubSource)
registerHooks({
resolve(specifier, context, nextResolve) {
if (specifier === 'kody:runtime') return { url: stubUrl, shortCircuit: true }
return nextResolve(specifier, context)
},
})