How to use the react-testing-library.wait function in react-testing-library

To help you get started, we’ve selected a few react-testing-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kentcdodds / stop-runaway-react-effects / src / __tests__ / index.js View on Github external
} else {
          // something else is up
          throw e
        }
      }
    }, deps)
  }

  hijackEffects({callCount: 2})

  let rendered = false

  // it's super weird, but somehow the error is not try/catchable here, but
  // it still fails the test. It's really odd. So we do some weird stuff to make
  // sure we wait for it to be thrown.
  await wait(
    () => {
      if (!rendered) {
        rendered = true
        render(ui)
      }
      expect(console.warn).toHaveBeenCalledTimes(1)
    },
    {timeout: 500},
  )
}
github flow-typed / flow-typed / definitions / npm / react-testing-library_v2.0.x / flow_v0.58.0- / test_react-testing-library_v2.0.x.js View on Github external
it('should fail on invalid inputs', () => {
    // $ExpectError
    wait(1);
    // $ExpectError
    wait(() => {}, 1);
  });
github flow-typed / flow-typed / definitions / npm / react-testing-library_v5.x.x / flow_v0.67.1- / test_react-testing-library_v5.x.x.js View on Github external
it('should fail on invalid inputs', () => {
    // $ExpectError
    wait(1);
    // $ExpectError
    wait(() => {}, 1);
  });
github flow-typed / flow-typed / definitions / npm / react-testing-library_v5.x.x / flow_v0.67.1- / test_react-testing-library_v5.x.x.js View on Github external
it('should fail on invalid inputs', () => {
    // $ExpectError
    wait(1);
    // $ExpectError
    wait(() => {}, 1);
  });
github flow-typed / flow-typed / definitions / npm / react-testing-library_v2.0.x / flow_v0.58.0- / test_react-testing-library_v2.0.x.js View on Github external
it('should fail on invalid inputs', () => {
    // $ExpectError
    wait(1);
    // $ExpectError
    wait(() => {}, 1);
  });