Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tests): migrate to vitest #57

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ module.exports = {
env: {
node: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vitest/recommended',
'prettier',
],
overrides: [
{
files: './**/*.{spec,test}.{js,jsx,ts,tsx}',
Expand All @@ -30,7 +35,7 @@ module.exports = {
ecmaVersion: '',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'vitest'],
root: true,
rules: {
'@typescript-eslint/no-unused-vars': noUnusedVarRule,
Expand All @@ -47,5 +52,22 @@ module.exports = {
},
],
'no-unused-vars': 'off',
// Vitest rules
'vitest/consistent-test-it': [
'warn',
{
fn: 'it',
withinDescribe: 'it',
},
],
'vitest/max-nested-describe': [
'error',
{
max: 5,
},
],
'vitest/no-commented-out-tests': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/prefer-to-be': 'off',
},
};
20 changes: 13 additions & 7 deletions .github/workflows/build-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ["16.14"]
node: ["20"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: ${{ matrix.node }}
cache: "npm"
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install Dependencies
run: npm install
run: pnpm install

- name: Create "dist/" Folder Contents
run: npm run build
run: pnpm build

- name: Create Package
run: npm pack
24 changes: 15 additions & 9 deletions .github/workflows/essential-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,33 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ["16.14"]
node: ["20"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: ${{ matrix.node }}
cache: "npm"
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install Dependencies
run: npm install
run: pnpm install

- name: Scan Vulnerabilities
run: npm audit --production

- name: Format
run: npm run format
run: pnpm format

- name: Lint
run: npm run eslint
run: pnpm eslint

- name: Test Unit
run: npm run test:ci
run: pnpm test:ci
21 changes: 15 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@ jobs:
needs: [essential]

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20 ]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: "16.14"
cache: "npm"
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
registry-url: https://npm.pkg.github.com/
scope: "@owner-or-organization"

- name: Install dependencies
run: npm install
run: pnpm install

- name: Build Distribution
run: npm run build
run: pnpm build

- name: Publish
run: npm publish
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ on:
jobs:
check-bundle-size:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20 ]
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLinters/eslint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/package-starter.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading