Impl test by toBeInTheDocument()

This commit is contained in:
porink0424
2024-04-05 13:22:33 +09:00
parent 38b64c75de
commit 28c865d47a
7 changed files with 40 additions and 3 deletions
+1
View File
@@ -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",
+1
View File
@@ -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",
+3 -1
View File
@@ -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()
})
}
})
+3 -1
View File
@@ -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()
})
}
})
+22
View File
@@ -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"]
}
+9
View File
@@ -0,0 +1,9 @@
import "@testing-library/jest-dom/vitest"
declare global {
namespace jest {
interface Matchers<R> {
toBeInTheDocument(): R
}
}
}
+1 -1
View File
@@ -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"],