diff --git a/src/__tests__/act.js b/src/__tests__/act.js index 49729f3b..5f3cbfb5 100644 --- a/src/__tests__/act.js +++ b/src/__tests__/act.js @@ -14,6 +14,12 @@ test('render calls useEffect immediately', () => { expect(effectCb).toHaveBeenCalledTimes(1) }) +test('findByTestId returns the element', async () => { + const ref = React.createRef() + const {findByTestId} = render(
) + expect(await findByTestId('foo')).toBe(ref.current) +}) + test('fireEvent triggers useEffect calls', () => { const effectCb = jest.fn() function Counter() { diff --git a/src/index.js b/src/index.js index fe6b259b..379fccbc 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,13 @@ import { import act, {asyncAct} from './act-compat' configureDTL({ - asyncWrapper: asyncAct, + asyncWrapper: async cb => { + let result + await asyncAct(async () => { + result = await cb() + }) + return result + }, }) const mountedContainers = new Set()