Make DataTable / DataInspector unit tests predictable

Summary: Having time / async / non-blocking behavior in components in unit tests is really annoying, as it makes unit tests async without an easy way to determine 'done'. This diff makes sure that DataTable & DataInspector don't break down their work in smaller tasks, but do everything block if they are running in a unit test.

Reviewed By: nikoant

Differential Revision: D28054487

fbshipit-source-id: 72c3b519e092ad69ed71eb1731e1fed80022f91f
This commit is contained in:
Michel Weststrate
2021-04-28 06:32:09 -07:00
committed by Facebook GitHub Bot
parent 39be769bab
commit bbcb16d8fb
8 changed files with 48 additions and 77 deletions

View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
/**
* Check if we are currently running a unit test.
* Use this hook to disable certain functionality that is probably not going to work as expected in the JSDom implementaiton
*/
export function useInUnitTest(): boolean {
return process.env.NODE_ENV === 'test';
}