Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Typecheck
run: pnpm typecheck

- name: Test
run: pnpm test
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A generic library template starter for brand new libraries.
| 🔍 PR Preview | Optional package preview builds for every PR and commit with [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) |
| 🎯 TypeScript Ready | Full TypeScript support with strict type checking |
| 🧹 Code Quality | ESLint and Prettier pre-configured for code quality |
| 🧪 Testing Ready | **Vitest** + **Testing Library** pre-configured, with CI running on every PR |
| ⚛️ React Support | React support with proper peer dependencies **React 19** + **React Compiler** ready |
| 🔒 Type Safety | Strict TypeScript configuration for better type safety |

Expand Down Expand Up @@ -49,6 +50,22 @@ Then **manually** remove the peerDependencies section from `package.json` and al

<br/>

## 🧪 Testing

This template ships test-ready with [Vitest](https://vitest.dev) and [Testing Library](https://testing-library.com), running in a `jsdom` environment so you can test both plain logic and React components.

```bash
# Run the suite once
pnpm test

# Run in watch mode while developing
pnpm test:watch
```

Tests live next to the source as `*.test.ts` / `*.test.tsx` files (see `packages/core/*.test.*` for examples). The included `.github/workflows/ci.yml` workflow typechecks and runs the suite on every pull request.

<br/>

## 🤖 Automatic Workflows

This template comes with two GitHub Actions workflows (currently disabled for convenience):
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"build": "tsup",
"dev": "tsup --watch",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"version:package": "pnpm changeset version",
"release": "pnpm build && pnpm changeset publish",
"lint": "eslint -c ./eslint.config.mjs . --fix --no-cache"
Expand All @@ -33,6 +35,9 @@
"devDependencies": {
"@changesets/cli": "^2.27.11",
"@eslint/js": "^9.18.0",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/node": "^20.11.24",
"@types/react": "^19.2.14",
"@typescript-eslint/eslint-plugin": "^8.21.0",
Expand All @@ -43,11 +48,14 @@
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
"globals": "^15.14.0",
"jsdom": "^29.1.1",
"prettier": "^3.4.2",
"react": "^19.2.4",
"react-dom": "19.2.4",
"tsup": "^8.0.2",
"typescript": "^5.7.3",
"typescript-eslint": "^8.21.0"
"typescript-eslint": "^8.21.0",
"vitest": "^3.2.6"
},
"peerDependencies": {
"react": ">=16.8.0"
Expand Down
17 changes: 17 additions & 0 deletions packages/core/core.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'

import { GenericComponent, useGenericHook } from './core'

describe('GenericComponent', () => {
it('renders its content', () => {
render(<GenericComponent />)
expect(screen.getByText('GenericComponent')).toBeInTheDocument()
})
})

describe('useGenericHook', () => {
it('returns the expected value', () => {
expect(useGenericHook()).toBe('GenericHook')
})
})
11 changes: 11 additions & 0 deletions packages/core/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest'

import { VERSION } from './index'
import { version } from '../../package.json'

describe('VERSION', () => {
it('is exported and matches package.json', () => {
expect(VERSION).toBe(version)
expect(VERSION).toMatch(/^\d+\.\d+\.\d+/)
})
})
Loading
Loading