diff --git a/tslib/react/package-lock.json b/tslib/react/package-lock.json index 1c53d463..c0fba30b 100644 --- a/tslib/react/package-lock.json +++ b/tslib/react/package-lock.json @@ -29,6 +29,7 @@ "@storybook/react": "^8.0.4", "@storybook/react-vite": "^8.0.4", "@storybook/test": "^8.0.4", + "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.2", "@types/plotly.js-dist-min": "^2.3.4", "@types/react": "^18.2.55", diff --git a/tslib/react/package.json b/tslib/react/package.json index 8780d543..545b3844 100644 --- a/tslib/react/package.json +++ b/tslib/react/package.json @@ -46,6 +46,7 @@ "@storybook/react": "^8.0.4", "@storybook/react-vite": "^8.0.4", "@storybook/test": "^8.0.4", + "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.2", "@types/plotly.js-dist-min": "^2.3.4", "@types/react": "^18.2.55", diff --git a/tslib/react/test/PlotHistory.test.tsx b/tslib/react/test/PlotHistory.test.tsx index 072a5ae9..d323f667 100644 --- a/tslib/react/test/PlotHistory.test.tsx +++ b/tslib/react/test/PlotHistory.test.tsx @@ -26,7 +26,9 @@ describe("PlotHistory Tests", async () => { for (const study of window.mockStudies) { test(`PlotHistory (studyId: ${study.study_id})`, () => { setup({ study, dataTestId: `plot-history-${study.study_id}` }) - expect(screen.getByTestId(`plot-history-${study.study_id}`)).toBeTruthy() + expect( + screen.getByTestId(`plot-history-${study.study_id}`) + ).toBeInTheDocument() }) } }) diff --git a/tslib/react/test/TrialTable.test.tsx b/tslib/react/test/TrialTable.test.tsx index 0df91933..e041f3e3 100644 --- a/tslib/react/test/TrialTable.test.tsx +++ b/tslib/react/test/TrialTable.test.tsx @@ -26,7 +26,9 @@ describe("TrialTable Tests", async () => { for (const study of window.mockStudies) { test(`TrialTable (studyId: ${study.study_id})`, () => { setup({ study, dataTestId: `trial-table-${study.study_id}` }) - expect(screen.getByTestId(`trial-table-${study.study_id}`)).toBeTruthy() + expect( + screen.getByTestId(`trial-table-${study.study_id}`) + ).toBeInTheDocument() }) } }) diff --git a/tslib/react/test/tsconfig.json b/tslib/react/test/tsconfig.json new file mode 100644 index 00000000..27d8dad1 --- /dev/null +++ b/tslib/react/test/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "isolatedModules": true, + "skipLibCheck": true, + "strictNullChecks": true, + "moduleResolution": "Node", + "noUnusedLocals": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noImplicitAny": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "target": "ES2020", + "strict": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "jsx": "react-jsx" + }, + "include": ["**/*.ts", "**/*.tsx"] +} diff --git a/tslib/react/test/vitest_setup.ts b/tslib/react/test/vitest_setup.ts new file mode 100644 index 00000000..a78f2b49 --- /dev/null +++ b/tslib/react/test/vitest_setup.ts @@ -0,0 +1,9 @@ +import "@testing-library/jest-dom/vitest" + +declare global { + namespace jest { + interface Matchers { + toBeInTheDocument(): R + } + } +} diff --git a/tslib/react/vite.config.ts b/tslib/react/vite.config.ts index 4ff53451..4a41b291 100644 --- a/tslib/react/vite.config.ts +++ b/tslib/react/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ plugins: [react()], test: { environment: "jsdom", - setupFiles: ["./test/setup_studies.ts"], + setupFiles: ["./test/vitest_setup.ts", "./test/setup_studies.ts"], }, optimizeDeps: { exclude: ["@sqlite.org/sqlite-wasm"],