Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Document testing utils #55

Open
JulienPradet opened this issue Mar 21, 2019 · 0 comments
Open

Document testing utils #55

JulienPradet opened this issue Mar 21, 2019 · 0 comments

Comments

@JulienPradet
Copy link
Contributor

In a recent Pull Request, I've added a mock implementation of a dataloader to test a certain behavior of one of my loader. We should document these kind of mock/helpers functions dedicated to testing.

@real34 mentioned that we could add a Testing section containing these kinds of things.

So let's do this! :)


A few notes about the mock implementation of a dataloader :

import {
  createLoader,
  hasMockDataloaderCache,
  resetAllMockDataloaders
} from "src/server/core/cache/strategies/mock.js";
  • createLoader behaves exactly like the memoize.createLoader
  • hasMockDataloaderCache(key, id) lets you know if a certain value is already cached for a particular dataloader
  • resetAllMockDataloaders resets all your dataloaders (you usually want to call this function before/after each test.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant