felangel / felangel/bloc

docs: testing initial events

Open
#4,229 10 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Dart
Stars
12.5k
Forks
3.4k
PR merge metrics
No merged PRs in 30d

Description

**Description**

Hi!

In #3944, it's mentioned that the recommended way to add initial events to a Bloc is as follows:

```
BlocProvider(
create: (context) => MeetingsBloc()..add(LoadMettingsEvent()),
child: MyWidget(),
);
```

The reasoning being that
> this gives you granular control over when the event is added and makes testing easier and more predictable. In addition, it also makes the bloc more flexible and reusable.

However, this creates a new problem. How do you test that the correct initial events are added when the Bloc is created?
As far as I know, none of the Bloc examples or documentation demonstrate a way to do this.

Is adding the initial events not considered worth testing?

Related issues: #3946, #3944, #3759, #2701, #2654, #1912, #1415

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.