Skip to content

Commit 440e37c

Browse files
Create unit test and GitHub Actions (#294)
* Update CI workflow, dependencies, and add Vitest for testing Co-authored-by: overtorment <overtorment@gmail.com> * Remove Vitest UI and related configuration Co-authored-by: overtorment <overtorment@gmail.com> * Move string utils tests to dedicated tests directory Co-authored-by: overtorment <overtorment@gmail.com> * Update CI workflow to separate lint and test jobs Co-authored-by: overtorment <overtorment@gmail.com> * Rename vitest.config.ts to vitest.config.mts Co-authored-by: overtorment <overtorment@gmail.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 1a8049a commit 440e37c

File tree

13 files changed

+3521
-117
lines changed

13 files changed

+3521
-117
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
name: Tests
1+
name: CI
22

33
on: [pull_request]
44

55
jobs:
66
lint:
7-
runs-on: macos-latest
7+
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout project
1010
uses: actions/checkout@v3
1111

12-
- name: Specify node version
13-
uses: actions/setup-node@v2-beta
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v3
1414
with:
15-
node-version: 16
15+
node-version: 18
16+
cache: "npm"
1617

17-
- name: Use npm caches
18-
uses: actions/cache@v2
19-
with:
20-
path: ~/.npm
21-
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
22-
restore-keys: |
23-
${{ runner.os }}-npm-
24-
25-
- name: Use node_modules caches
26-
id: cache-nm
27-
uses: actions/cache@v2
18+
- name: Install dependencies
19+
run: npm ci
20+
21+
- name: Run linting
22+
run: npm run lint
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout project
28+
uses: actions/checkout@v3
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v3
2832
with:
29-
path: node_modules
30-
key: ${{ runner.os }}-nm-${{ hashFiles('package-lock.json') }}
33+
node-version: 18
34+
cache: "npm"
3135

32-
- name: Install node_modules
33-
if: steps.cache-nm.outputs.cache-hit != 'true'
34-
run: npm install
36+
- name: Install dependencies
37+
run: npm ci
3538

3639
- name: Run tests
37-
run: npm run lint
40+
run: npm run test:run

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Set them as env variables or put them into `.env` file in project root dir.
9696
- `GOOGLE_KEY_FILE` - json file with Google key for FCM, in hex
9797
- `GOOGLE_PROJECT_ID` - acquired with the key file
9898

99-
10099
### Getting certificates
101100

102101
- outdated https://dev.to/jakubkoci/react-native-push-notifications-313i

TESTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Testing
2+
3+
This project uses [Vitest](https://vitest.dev/) for unit testing.
4+
5+
## Running Tests
6+
7+
```bash
8+
# Run tests once
9+
npm run test:run
10+
11+
# Run tests in watch mode
12+
npm test
13+
```
14+
15+
## Test Structure
16+
17+
Tests are located in the `src/tests/` directory with the `.test.ts` suffix.
18+
19+
Current test coverage includes:
20+
21+
- `StringUtils` - Utility functions for shortening addresses and transaction IDs
22+
23+
## GitHub Actions
24+
25+
The CI pipeline runs on every pull request via GitHub Actions with two separate jobs:
26+
27+
### Lint Job
28+
29+
1. Sets up Node.js 18
30+
2. Installs dependencies
31+
3. Runs linting (Prettier + TypeScript compilation)
32+
33+
### Test Job
34+
35+
1. Sets up Node.js 18
36+
2. Installs dependencies
37+
3. Executes the test suite
38+
39+
Both jobs run in parallel for faster feedback. The workflow file is located at `.github/workflows/ci.yml`.

0 commit comments

Comments
 (0)