Skip to content

Commit

Permalink
build(ci): add github action for running unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kahboom committed Mar 19, 2024
1 parent 104bdcb commit ac0983a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 🧪 Unit Tests (Jest)

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: 🧪 Unit Tests (Jest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 📦 Install modules
run: npm install
- name: ⚙️ Run tests
run: npm run test --coverage
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ npm run dev

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

## Tests

### Unit Tests

Run all [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) unit tests:

```bash
npm run test
```

Launches the test runner in the interactive watch mode.

Tests are colocated and live as closely to corresponding code as possible.

## Deploy

The app is based on [Next.JS](https://nextjs.org/) and is automatically built & deployed to GitHub Pages when pushing to the `main` branch.
Expand Down
22 changes: 22 additions & 0 deletions src/modules/components/Entry.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { render } from "@testing-library/react";
import { RekorClientProvider } from "../api/context";
import { EntryCard } from "./Entry";

describe("Entry", () => {
it("renders", () => {
//
});
});

describe("EntryCard", () => {
it("renders", () => {
render(
<RekorClientProvider>
<EntryCard
content={<></>}
title={<></>}
/>
</RekorClientProvider>,
);
});
});
16 changes: 16 additions & 0 deletions src/modules/components/SearchForm.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SearchForm } from "./SearchForm";
import { render } from "@testing-library/react";
import { RekorClientProvider } from "../api/context";

describe("SearchForm", () => {
it("renders", () => {
render(
<RekorClientProvider>
<SearchForm
isLoading={false}
onSubmit={() => {}}
/>
</RekorClientProvider>,
);
});
});
16 changes: 16 additions & 0 deletions src/modules/components/Settings.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { render } from "@testing-library/react";
import { RekorClientProvider } from "../api/context";
import { Settings } from "./Settings";

describe("Settings", () => {
it("renders", () => {
render(
<RekorClientProvider>
<Settings
onClose={jest.fn()}
open={true}
/>
</RekorClientProvider>,
);
});
});

0 comments on commit ac0983a

Please sign in to comment.