Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
180ea1d
feat: add test suite with GitHub Actions workflow and React version c…
davemecha Jun 27, 2025
0de56fe
feat: add cross-version React testing compatibility layer and fix typ…
davemecha Jun 27, 2025
369739b
chore: add CodeRabbit config for main and develop branch reviews
davemecha Jun 28, 2025
9910b50
feat: add matrix testing across React 16-19 and Node 16-20 versions
davemecha Jun 28, 2025
66e5ae7
fix: add conditional testing library versions based on React version …
davemecha Jun 28, 2025
8614712
chore: add @testing-library/react dependency for React version compat…
davemecha Jun 28, 2025
6613265
test: add comprehensive test coverage for edge cases and error handli…
davemecha Jun 29, 2025
acf2a47
chore: update Codecov action from v3 to v4
davemecha Jun 29, 2025
e789659
add comment for any type usage
davemecha Jun 29, 2025
c2d7eaf
chore: add strict error handling to matrix test script with set -euo …
davemecha Jun 30, 2025
f6a26d8
fix: add error handling and exit codes to matrix test script
davemecha Jun 30, 2025
e3797cf
style: improve readability of conditional npm install in Dockerfile.test
davemecha Jun 30, 2025
818c4ef
chore: remove --force flag from npm install commands in test setup
davemecha Jun 30, 2025
f2e24dd
Merge pull request #3 from davemecha/testing
davemecha Jun 30, 2025
f62fb6e
reset version to pre-release version
davemecha Jun 30, 2025
e99d4a5
fix: downgrade testing-library/react to v16.1.0 for React 19 test script
davemecha Jun 30, 2025
d328ea0
fix: update test dependencies installation for different React versio…
davemecha Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
reviews:
base_branches:
- "main"
- "develop"
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Test

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
react-version: ["16.8.0", "17.0.0", "18.0.0", "19.0.0"]
node-version: [16, 18, 20]
exclude:
# React 19 requires Node 18+
- react-version: "19.0.0"
node-version: 16

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Install React and testing libraries for React ${{ matrix.react-version }}
run: |
if [[ "${{ matrix.react-version }}" == "16.8.0" || "${{ matrix.react-version }}" == "17.0.0" ]]; then
npm install react@^${{ matrix.react-version }} react-dom@^${{ matrix.react-version }} @types/react@^${{ matrix.react-version }} @types/react-dom@^${{ matrix.react-version }} @testing-library/react@^12.1.5 @testing-library/react-hooks@^8.0.1
elif [[ "${{ matrix.react-version }}" == "18.0.0" ]]; then
npm install react@^${{ matrix.react-version }} react-dom@^${{ matrix.react-version }} @types/react@^${{ matrix.react-version }} @types/react-dom@^${{ matrix.react-version }} @testing-library/react@^14.1.0
else
npm install react@^${{ matrix.react-version }} react-dom@^${{ matrix.react-version }} @types/react@^${{ matrix.react-version }} @types/react-dom@^${{ matrix.react-version }} @testing-library/react@^16.1.0
fi

- name: Run tests
run: npm test -- --coverage --watchAll=false

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage/lcov.info
flags: react-${{ matrix.react-version }}-node-${{ matrix.node-version }}
name: codecov-umbrella
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Check types
run: npx tsc --noEmit
39 changes: 39 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG NODE_VERSION
ARG REACT_VERSION

FROM node:${NODE_VERSION}-slim

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm ci

# Conditionally install testing libraries based on React version
RUN if [ "${REACT_VERSION}" = "16.8.0" ] || [ "${REACT_VERSION}" = "17.0.0" ]; then \
npm install \
"react@${REACT_VERSION}" \
"react-dom@${REACT_VERSION}" \
"@types/react@${REACT_VERSION}" \
"@types/react-dom@${REACT_VERSION}" \
"@testing-library/react@^12.1.5" \
"@testing-library/react-hooks@^8.0.1"; \
elif [ "${REACT_VERSION}" = "18.0.0" ]; then \
npm install \
"react@${REACT_VERSION}" \
"react-dom@${REACT_VERSION}" \
"@types/react@${REACT_VERSION}" \
"@types/react-dom@${REACT_VERSION}" \
"@testing-library/react@^14.1.0"; \
else \
npm install \
"react@${REACT_VERSION}" \
"react-dom@${REACT_VERSION}" \
"@types/react@${REACT_VERSION}" \
"@types/react-dom@${REACT_VERSION}" \
"@testing-library/react@^16.1.0"; \
fi

COPY . .

CMD npm test -- --coverage --watchAll=false
Loading