Testing Asynchronous State Update in React Component not possible #6031
-
Describe the bugI tried various combinations and non of them helped to execute test properly. Basically if you try to fire onChange event on input field in your component and that onChange has timeout set which will call setState when cb executed. Reproduction
output is: Component did mount System Infovite.config.ts:
test: {
globals: true,
environment: 'happy-dom',
setupFiles: './src/setupTests.ts',
include: ['src/**/*.test.{js,ts,jsx,tsx}'],
exclude: [...configDefaults.exclude, '**/node_modules/**', '**/build/**']
},
setupTests.ts
import '@testing-library/jest-dom';
import * as matchers from '@testing-library/jest-dom/matchers';
import { cleanup } from '@testing-library/react';
afterEach(() => {
cleanup();
});
expect.extend(matchers); Used Package Managernpm Validations
|
Beta Was this translation helpful? Give feedback.
Answered by
Muhamedkaric
Jul 5, 2024
Replies: 1 comment
-
Solution is to use it like this:
key points:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Muhamedkaric
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution is to use it like this:
key points: