freenowtech / freenowtech/wave

DOM behaviour is not always properly emulated when testing

Open
#173 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
67
Forks
31
Avg merge
1d 8h
Merged PRs (30d)
4

Description

When doing integration tests that use `userEvent` we are not waiting for the DOM "update" but directly expecting behaviour.

- `@freenow/wave` version: 1.14.0

### Relevant code (this is just a pseudo-code example)
In some cases we are using `userEvent` like this
```js
// Simulate an input change
userEvent.type(input, 'some text');

expect(something).toHaveHappened();
```
We should instead do this in order to correctly emulate the behaviour the user would see in the browser
```js
// Simulate an input change
userEvent.type(input, 'some text');

await waitFor(() => expect(something).toHaveHappened());
```

### What was expected to happen?

When running tests this warning appears
`Warning: An update to X inside a test was not wrapped in act(...). `

After the PR for this issue is merged we should not see this warning anymore while running tests

Depends on #163

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.