We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The current way to mock a KV store is
https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L64-L77
The function adds a mock for the KV to the global namespace. With this approach we need a generic variable setting at https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L67 and the line https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L64 is a duplication of the definition at https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/src/kv.d.ts#L22-L28
A solution is to create a function createKV() at __tests__/__utils__/index.ts with the signature:
createKV()
__tests__/__utils__/index.ts
export function createKV<Keys extends string>(): KV<Keys> { ... }
Then we can use this function in our test code with for example
global.PATH_INFO_KV = createKV()
See https://developers.cloudflare.com/workers/runtime-apis/kv for a doc what a KV store is.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
The current way to mock a KV store is
https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L64-L77
The function adds a mock for the KV to the global namespace. With this approach we need a generic variable setting at https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L67 and the line https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/__tests__/_helper.ts#L64 is a duplication of the definition at https://github.com/serlo/serlo.org-cloudflare-worker/blob/c96e71181f854840b335edb1118add87e3917042/src/kv.d.ts#L22-L28
A solution is to create a function
createKV()
at__tests__/__utils__/index.ts
with the signature:Then we can use this function in our test code with for example
See https://developers.cloudflare.com/workers/runtime-apis/kv for a doc what a KV store is.
The text was updated successfully, but these errors were encountered: