docs
docs copied to clipboard
Explain how `.provide()` can not be called imperatively to override implementations
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| docs | ✅ Ready (Inspect) | Visit Preview | Jul 11, 2023 9:26am |
Does the new setup() api make this PR obsolete? @Andarist @davidkpiano
Not exactly. With setup you have to "provide" all implementations upfront - so you should never end up with missing implementations but you can still override/mock them afterward. This works just fine today:
setup({
actors: {
fetchUser: fromPromise(() => fetch("/user")),
},
})
.createMachine({})
.provide({
actors: {
fetchUser: fromPromise(() => Promise.resolve({ name: "Kevin" })),
},
});