Skip to content

Commit f8d790b

Browse files
committed
test: add minimal tests integration and e2e
1 parent 6736821 commit f8d790b

13 files changed

Lines changed: 1210 additions & 138 deletions

File tree

.github/workflows/test.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [20, 22]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v4
30+
31+
- name: Get pnpm store directory
32+
id: pnpm-cache
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
36+
37+
- name: Setup pnpm cache
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
41+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pnpm-store-
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Build packages
49+
run: pnpm --filter babel-plugin-kstyled --filter kstyled build
50+
51+
- name: Run tests
52+
run: pnpm --filter babel-plugin-kstyled --filter kstyled test
53+
54+
coverage:
55+
runs-on: ubuntu-latest
56+
needs: test
57+
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Node.js
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: '20'
66+
67+
- name: Setup pnpm
68+
uses: pnpm/action-setup@v4
69+
70+
- name: Get pnpm store directory
71+
id: pnpm-cache
72+
shell: bash
73+
run: |
74+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
75+
76+
- name: Setup pnpm cache
77+
uses: actions/cache@v4
78+
with:
79+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
80+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
81+
restore-keys: |
82+
${{ runner.os }}-pnpm-store-
83+
84+
- name: Install dependencies
85+
run: pnpm install --frozen-lockfile
86+
87+
- name: Build packages
88+
run: pnpm --filter babel-plugin-kstyled --filter kstyled build
89+
90+
- name: Run tests with coverage
91+
run: pnpm --filter babel-plugin-kstyled --filter kstyled test -- --coverage
92+
93+
- name: Upload coverage to Codecov
94+
uses: codecov/codecov-action@v4
95+
with:
96+
files: ./coverage/lcov.info
97+
flags: unittests
98+
name: codecov-umbrella
99+
fail_ci_if_error: false

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# kstyled
22

33
[![CI](https://github.com/hyodotdev/kstyled/actions/workflows/ci.yml/badge.svg)](https://github.com/hyodotdev/kstyled/actions/workflows/ci.yml)
4+
[![Tests](https://github.com/hyodotdev/kstyled/actions/workflows/test.yml/badge.svg)](https://github.com/hyodotdev/kstyled/actions/workflows/test.yml)
45
[![npm version](https://img.shields.io/npm/v/kstyled.svg)](https://www.npmjs.com/package/kstyled)
56
[![npm downloads](https://img.shields.io/npm/dm/kstyled.svg)](https://www.npmjs.com/package/kstyled)
67
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"devDependencies": {
4444
"@turbo/gen": "^2.3.3",
45+
"@types/jest": "^29.5.14",
4546
"prettier": "^3.4.2",
4647
"turbo": "^2.3.3",
4748
"typescript": "^5.7.2"

packages/babel-plugin-kstyled/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ module.exports = {
1717
},
1818
}],
1919
},
20+
watchman: false,
2021
};

packages/kstyled/eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const tsparser = require('@typescript-eslint/parser');
44
module.exports = [
55
{
66
files: ['**/*.ts', '**/*.tsx'],
7+
ignores: ['**/__tests__/**'],
78
languageOptions: {
89
parser: tsparser,
910
parserOptions: {
@@ -23,6 +24,28 @@ module.exports = [
2324
'@typescript-eslint/no-empty-object-type': 'warn',
2425
},
2526
},
27+
{
28+
files: ['**/__tests__/**/*.ts', '**/__tests__/**/*.tsx'],
29+
languageOptions: {
30+
parser: tsparser,
31+
parserOptions: {
32+
ecmaVersion: 2021,
33+
sourceType: 'module',
34+
},
35+
},
36+
plugins: {
37+
'@typescript-eslint': tseslint,
38+
},
39+
rules: {
40+
...tseslint.configs.recommended.rules,
41+
'@typescript-eslint/no-explicit-any': 'off',
42+
'@typescript-eslint/explicit-module-boundary-types': 'off',
43+
'@typescript-eslint/no-unused-vars': 'warn',
44+
'@typescript-eslint/no-empty-object-type': 'off',
45+
'@typescript-eslint/ban-ts-comment': 'off',
46+
'@typescript-eslint/no-require-imports': 'off',
47+
},
48+
},
2649
{
2750
ignores: ['dist/', 'node_modules/', '*.config.js'],
2851
},

packages/kstyled/jest.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/src'],
5+
testMatch: ['**/__tests__/**/*.test.{ts,tsx}'],
6+
collectCoverageFrom: [
7+
'src/**/*.{ts,tsx}',
8+
'!src/**/*.d.ts',
9+
'!src/**/__tests__/**',
10+
],
11+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
12+
transform: {
13+
'^.+\\.tsx?$': [
14+
'ts-jest',
15+
{
16+
tsconfig: {
17+
jsx: 'react',
18+
esModuleInterop: true,
19+
},
20+
},
21+
],
22+
},
23+
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
24+
watchman: false,
25+
};

packages/kstyled/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
"react-native": ">=0.64.0"
4343
},
4444
"devDependencies": {
45+
"@babel/core": "^7.26.0",
46+
"@babel/preset-react": "^7.26.0",
47+
"@babel/preset-typescript": "^7.26.0",
48+
"@types/babel__core": "^7.20.5",
4549
"@types/react": "~19.1.10",
4650
"@types/react-native": "^0.73.0",
4751
"@typescript-eslint/eslint-plugin": "^8.19.1",
@@ -50,6 +54,7 @@
5054
"jest": "^29.7.0",
5155
"react": "19.1.0",
5256
"react-native": "0.81.5",
57+
"ts-jest": "^29.2.5",
5358
"tsup": "^8.3.5",
5459
"typescript": "^5.7.2"
5560
}

0 commit comments

Comments
 (0)