diff --git a/test/helpers/userEventSetup.ts b/test/helpers/userEventSetup.ts new file mode 100644 index 00000000..7c24a489 --- /dev/null +++ b/test/helpers/userEventSetup.ts @@ -0,0 +1,13 @@ +import realUserEvent from "@testing-library/user-event"; + +/** + * Setup user-event instance with custom defaults + */ +export function userEventSetup( + options: Parameters[0] = {} +): ReturnType { + return realUserEvent.setup({ + advanceTimers: jest.advanceTimersByTime, + ...options, + }); +} diff --git a/test/setup.ts b/test/setup.ts new file mode 100644 index 00000000..bf80e5fb --- /dev/null +++ b/test/setup.ts @@ -0,0 +1,8 @@ +import "@testing-library/jest-dom"; +import "whatwg-fetch"; + +import { configure } from "@testing-library/react"; + +configure({ + throwSuggestions: true, +}); diff --git a/test/teardown.ts b/test/teardown.ts new file mode 100644 index 00000000..281ca4c2 --- /dev/null +++ b/test/teardown.ts @@ -0,0 +1,12 @@ +import path from "path"; + +export default function teardown(): void { + console.log(` +================================================================================ +View Coverage Report (Open in Browser): ${path.relative( + process.cwd(), + path.join(__dirname, "../coverage/lcov-report/index.html") + )} +================================================================================ +`); +} diff --git a/tsconfig.json b/tsconfig.json index c2e44abe..aa50c7e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,6 +27,6 @@ "importsNotUsedAsValues": "preserve", "incremental": true }, - "include": ["src", "webpack"], + "include": ["src", "webpack", "test"], "exclude": ["**/node_modules", "**/.*/"] } \ No newline at end of file