generated from UoaWDCC/ssr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from UoaWDCC/setup/test
setup vitest, jest and react testing library for testing
- Loading branch information
Showing
8 changed files
with
1,142 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect, it } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import React from "react"; | ||
import ExecScreen from "../src/screens/ExecScreen"; | ||
import { describe } from "node:test"; | ||
import { execs } from "../src/data/data"; | ||
|
||
describe("ExecScreen component", () => { | ||
it("should display President", () => { | ||
render(<ExecScreen execs={execs} />); | ||
const message = screen.getAllByText(/President/i); | ||
const president = message[0]; | ||
expect(president).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect, it } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import React from "react"; | ||
import TestScreen from "../src/screens/Test"; | ||
import { describe } from "node:test"; | ||
|
||
describe("TestScreen component", () => { | ||
it("should display the 'Test' message", () => { | ||
render(<TestScreen />); | ||
const message = screen.getByText(/Test/i); | ||
expect(message).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react-swc'; | ||
/// <reference types="vitest" /> | ||
|
||
import { defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react-swc"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: { | ||
alias: { | ||
'@utils': '/src/utils', | ||
'@components': '/src/components', | ||
'@pages': '/src/pages', | ||
'@contexts': '/src/contexts', | ||
'@layouts': '/src/layouts', | ||
"@utils": "/src/utils", | ||
"@components": "/src/components", | ||
"@pages": "/src/pages", | ||
"@contexts": "/src/contexts", | ||
"@layouts": "/src/layouts", | ||
"@screens": "/src/screens", | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// <reference types="vitest" /> | ||
/// <reference types = "vite/client" /> | ||
|
||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: "jsdom", | ||
setupFiles: ["./vitest.setup.ts"], | ||
css: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/jest-dom"; |
Large diffs are not rendered by default.
Oops, something went wrong.