Skip to content

Commit ac0983a

Browse files
committed
build(ci): add github action for running unit tests
1 parent 104bdcb commit ac0983a

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

.github/workflows/unit-tests.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 🧪 Unit Tests (Jest)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
build:
12+
name: 🧪 Unit Tests (Jest)
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: 📦 Install modules
17+
run: npm install
18+
- name: ⚙️ Run tests
19+
run: npm run test --coverage

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ npm run dev
1414

1515
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
1616

17+
## Tests
18+
19+
### Unit Tests
20+
21+
Run all [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) unit tests:
22+
23+
```bash
24+
npm run test
25+
```
26+
27+
Launches the test runner in the interactive watch mode.
28+
29+
Tests are colocated and live as closely to corresponding code as possible.
30+
1731
## Deploy
1832

1933
The app is based on [Next.JS](https://nextjs.org/) and is automatically built & deployed to GitHub Pages when pushing to the `main` branch.

src/modules/components/Entry.test.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { render } from "@testing-library/react";
2+
import { RekorClientProvider } from "../api/context";
3+
import { EntryCard } from "./Entry";
4+
5+
describe("Entry", () => {
6+
it("renders", () => {
7+
//
8+
});
9+
});
10+
11+
describe("EntryCard", () => {
12+
it("renders", () => {
13+
render(
14+
<RekorClientProvider>
15+
<EntryCard
16+
content={<></>}
17+
title={<></>}
18+
/>
19+
</RekorClientProvider>,
20+
);
21+
});
22+
});
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { SearchForm } from "./SearchForm";
2+
import { render } from "@testing-library/react";
3+
import { RekorClientProvider } from "../api/context";
4+
5+
describe("SearchForm", () => {
6+
it("renders", () => {
7+
render(
8+
<RekorClientProvider>
9+
<SearchForm
10+
isLoading={false}
11+
onSubmit={() => {}}
12+
/>
13+
</RekorClientProvider>,
14+
);
15+
});
16+
});
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { render } from "@testing-library/react";
2+
import { RekorClientProvider } from "../api/context";
3+
import { Settings } from "./Settings";
4+
5+
describe("Settings", () => {
6+
it("renders", () => {
7+
render(
8+
<RekorClientProvider>
9+
<Settings
10+
onClose={jest.fn()}
11+
open={true}
12+
/>
13+
</RekorClientProvider>,
14+
);
15+
});
16+
});

0 commit comments

Comments
 (0)