Skip to content

Commit f1bee6b

Browse files
marklundinCopilot
andauthored
Add Unit Tests (#115)
* Update dependencies and enhance testing setup - Removed outdated type definitions for React and React DOM from package-lock.json and package.json. - Added new devDependencies for testing, including vitest and testing-library packages for improved testing capabilities. - Updated scripts in package.json to include test commands for running tests across workspaces. - Refactored tsconfig.json to exclude test files from compilation. - Improved documentation in the entity page to ensure proper syntax and clarity. This commit enhances the testing framework and updates dependencies for better compatibility and performance. * Update dependencies and improve package configurations - Bump PlayCanvas version to 2.7.3 in package.json and package-lock.json for enhanced features. - Update ESLint and related packages to version 9.25.1 for improved linting capabilities. - Upgrade @types/react and @types/react-dom to 19.1.2 for better type definitions. - Refine devDependencies in package.json and packages/docs/package.json, including updates to @tailwindcss/postcss and next to version 15.3.1. - Add new license information for several packages to ensure compliance and clarity. These changes enhance compatibility, improve development experience, and ensure up-to-date dependencies across the project. * Update package-lock.json, tsconfig.json, and GitHub workflows - Updated package-lock.json to include resolved URLs and integrity hashes for various dependencies, enhancing security and reliability. - Modified tsconfig.json to exclude test files from compilation, improving build efficiency. - Refactored GitHub workflows (build.yml and test.yml) to simplify Node.js version management and streamline build and test steps, ensuring consistency across CI processes. - Removed the setup.ts test file as part of the cleanup process. These changes improve dependency management, enhance CI workflows, and optimize the testing setup. * Refactor asset fetching import in use-asset hook - Updated the import path for fetchAsset from "@playcanvas/react/utils" to "../utils/fetch-asset" to improve module organization and clarity. This change enhances the structure of the codebase by ensuring that asset fetching utilities are correctly referenced. * Fix rotation property type in MotionEntity component - Updated the rotation property in the MotionEntity component to ensure it correctly handles a three-element array, removing the optional fourth element. This change improves type consistency and prevents potential runtime errors. This update enhances the reliability of the MotionEntity component by ensuring proper data structure for rotation. * Update packages/lib/test/setup.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 0dd5630 commit f1bee6b

25 files changed

+3718
-519
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
33

44
name: Node.js CI
@@ -11,21 +11,25 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

17-
strategy:
18-
matrix:
19-
node-version: [18.x, 20.x, 22.x]
20-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21-
2216
steps:
2317
- uses: actions/checkout@v4
24-
- name: Use Node.js ${{ matrix.node-version }}
18+
19+
- name: Use Node.js
2520
uses: actions/setup-node@v4
2621
with:
27-
node-version: ${{ matrix.node-version }}
22+
node-version: '20.x'
2823
cache: 'npm'
29-
- run: npm ci
30-
- run: npm run build --if-present
31-
- run: npm run test --if-present
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build library
29+
run: npm run build:lib
30+
31+
- name: Run tests
32+
run: npm run test:lib
33+
34+
- name: Build docs
35+
run: npm run build:docs

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20.x'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run tests
26+
run: npm test
27+
28+
- name: Upload test results
29+
if: always()
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: test-results
33+
path: |
34+
packages/lib/coverage
35+
packages/lib/test-results.xml

0 commit comments

Comments
 (0)