Skip to content
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

Feature Request: Enhance TestClock with Automatic Time Management #2707

Open
dilame opened this issue May 7, 2024 · 0 comments
Open

Feature Request: Enhance TestClock with Automatic Time Management #2707

dilame opened this issue May 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dilame
Copy link
Contributor

dilame commented May 7, 2024

What is the problem this feature would solve?

Currently, TestClock requires manual time adjustments, making it cumbersome for testing complex asynchronous scenarios involving multiple parallel processes with varying delays.

const waitRandomTimeAndPrintCurrentTime = Effect.gen(function *(){
    const randomSleepTime = yield* Random.nextIntBetween(1000,5000);
    yield* Effect.sleep(randomSleepTime);
    const currentTime = yield* Clock.currentTimeMillis;
    yield* Console.log(currentTime);
})

const test = Effect.gen(function* () {
    yield* Effect.forkDaemon(waitRandomTimeAndPrintCurrentTime)
    yield* Effect.forkDaemon(waitRandomTimeAndPrintCurrentTime)
})

What is the feature you are proposing to solve the problem?

Enhance TestClock with automatic time management, similar to RxJS's VirtualTimeScheduler. This scheduler should have a flush() method that executes all queued actions and advances time accordingly. This feature would help create more realistic and comprehensive test scenarios without the need to manually simulate each time step.

What alternatives have you considered?

I considered using Clock.sleeps() to obtain the next scheduled event and then adjusting time to it manually. However, I could only retrieve an empty array during my tests. Maybe i did something wrong

@dilame dilame added the enhancement New feature or request label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant