-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Description
Describe the problem
@accuser made this observation here:
I like the simplicity of this approach, but it seems to take away the ability to pass context when mounting a component during testing. Or am I missing something obvious?
I used to do this:
mount(MyComponent, { props, context: { CONTEXT_TOKEN: mockContext }, target: document.body });Now that the context key is opaque, I don't seem to have a way to do this.
Describe the proposed solution
Maybe the key should be exposed (e.g. on the setter) to enable something like:
mount(MyComponent, { context: { [setContext.key]: mockContext }, /* ... */ });Or maybe a function for creating a context entry (key/value pair) could be provided, this way the type checking could still be automatically enforced:
mount(MyComponent, {
context: new Map([
setContext.entry(mockContext), // [{}, T]
// ... other contexts, e.g. via `...Object.entries({ ... })`
]),
// ...
});Importance
would make my life easier
Metadata
Metadata
Assignees
Labels
No labels