-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
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
Simplify @effect/vitest Test Effect API #4163
Comments
I kind of like: it.effect("message", function* () {
// ...
}) better than any alternative |
Don't forget test context. This might work well though. it.effect("message", function* (ctx) {
// ...
}) Or in the case of each or prop: it.effect("message", function* (ctx, item) {
// ...
}) |
I don't know if having the test context as a parameter of the generator function is possible, and if so that might just be the cleanest indeed, but otherwise we can just provide a service to fetch it too |
having it is indeed possible, what I am more worried about is instead pipeability, many times you need to add stuff like Today with it.effect(
"message",
Effect.fn(function*(ctx) {
ctx.expect(1).toBe(1)
})
) and piping would work like: it.effect(
"message",
Effect.fn(
function*(ctx) {
ctx.expect(1).toBe(1)
},
Effect.timeout("1 second")
)
) if we were to support the generator directly we would need tons of overloads to support pipes |
And also we would not have a place where to specify test config like: it.effect(
"message",
Effect.fn(
function*(ctx) {
ctx.expect(1).toBe(2)
},
Effect.timeout("1 second")
),
{ fails: true }
) If this becomes: it.effect(
"message",
function*(ctx) {
ctx.expect(1).toBe(2)
},
Effect.timeout("1 second")
) Where would we put |
Oh I didn't know about |
Oh alright I just learnt it's a new variant that got released today |
What is the problem this feature would solve?
At the moment, test effects in
@effect/vitest
are defined using the following pattern:Because
someEffect
is already a lazy computation, the arrow function feels redundant and does not simplify the developer experience.What is the feature you are proposing to solve the problem?
Replace the current API with a direct call, removing the unnecessary arrow function:
It would work on most cases, except when the function is actually used to pass an argument like in
but in these cases we could use an effect service like this:
Furthermore, since all use cases I can think about would just use
E.gen
, we could streamline this further by requiring the generator function directly:I’m willing to implement this feature if it aligns with the project's direction. Before proceeding, I'd like to confirm whether this approach is desirable for
@effect/vitest
.What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: