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

Replace unit test framework from floss to vitest #2396

Merged
merged 13 commits into from
Oct 22, 2024
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ jobs:

- name: Install
run: pnpm install
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build
run: npm run build
- name: Test
run: npm run test-cov
run: npm run coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"test": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss --path tests -r ts-node/register",
"test-debug": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss --path tests -r ts-node/register --debug",
"test-cov": "cross-env TS_NODE_PROJECT=tsconfig.tests.json IS_COV=1 nyc --reporter=lcov floss --path tests -r ts-node/register",
"installPlaywright": "pnpm exec playwright install",
"test": "pnpm run installPlaywright && vitest",
"coverage": "pnpm run installPlaywright && vitest --coverage",
"build": "npm run b:module && npm run b:types",
"lint": "eslint packages/*/src --ext .ts",
"watch": "cross-env NODE_ENV=release BUILD_TYPE=MODULE rollup -cw -m inline",
Expand All @@ -33,29 +33,25 @@
"@rollup/plugin-replace": "^2.3.4",
"@swc/core": "^1.3.49",
"@swc/helpers": "^0.5.1",
"@types/chai": "^4.3.1",
"@types/chai-spies": "^1.0.3",
"@types/mocha": "^8.0.0",
"@types/node": "^18.7.16",
"@types/webxr": "latest",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@vitest/coverage-v8": "2.1.3",
"bumpp": "^9.5.2",
"chai": "^4.3.6",
"chai-spies": "^1.0.0",
"cross-env": "^5.2.0",
"cypress": "^12.17.1",
"cypress-recurse": "^1.23.0",
"electron": "^13",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"floss": "^5.0.1",
"fs-extra": "^10.1.0",
"husky": "^8.0.0",
"lint-staged": "^10.5.3",
"nyc": "^15.1.0",
"odiff-bin": "^2.5.0",
"playwright": "^1.48.1",
"prettier": "^3.0.0",
"rollup": "^2.36.1",
"rollup-plugin-glslify": "^1.2.0",
Expand All @@ -64,7 +60,8 @@
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-swc3": "^0.10.1",
"ts-node": "^10",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vitest": "^2.1.3"
},
"lint-staged": {
"*.{ts}": [
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/animation/Keyframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ export class Keyframe<
T = V extends number
? number
: V extends Vector2
? Vector2
: V extends Vector3
? Vector3
: V extends Vector4 | Color | Quaternion | Rect
? Vector4
: V extends number[] | Float32Array
? number[]
: V extends ReferResource
? ReferResource
: never
? Vector2
: V extends Vector3
? Vector3
: V extends Vector4 | Color | Quaternion | Rect
? Vector4
: V extends number[] | Float32Array
? number[]
: V extends ReferResource
? ReferResource
: never
> {
/** The time of the Keyframe. */
time: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@
? srcCurve._evaluateAdditive(srcTime, this.baseEvaluateData)
: srcCurve._evaluate(srcTime, this.baseEvaluateData)
: additive
? this.cureType._getZeroValue(this.baseEvaluateData.value)
: this.defaultValue;
? this.cureType._getZeroValue(this.baseEvaluateData.value)

Check warning on line 95 in packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts#L95

Added line #L95 was not covered by tests
: this.defaultValue;

const destValue =
destCurve && destCurve.keys.length
? additive
? destCurve._evaluateAdditive(destTime, this.crossEvaluateData)
: destCurve._evaluate(destTime, this.crossEvaluateData)
: additive
? this.cureType._getZeroValue(this.crossEvaluateData.value)
: this.defaultValue;
? this.cureType._getZeroValue(this.crossEvaluateData.value)

Check warning on line 104 in packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts#L104

Added line #L104 was not covered by tests
: this.defaultValue;

return this._lerpValue(srcValue, destValue, crossWeight);
}
Expand All @@ -126,8 +126,8 @@
? destCurve._evaluateAdditive(destTime, this.crossEvaluateData)
: destCurve._evaluate(destTime, this.crossEvaluateData)
: additive
? this.cureType._getZeroValue(this.crossEvaluateData.value)
: this.defaultValue;
? this.cureType._getZeroValue(this.crossEvaluateData.value)

Check warning on line 129 in packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/animation/internal/animationCurveOwner/AnimationCurveOwner.ts#L129

Added line #L129 was not covered by tests
: this.defaultValue;

return this._lerpValue(srcValue, destValue, crossWeight);
}
Expand Down
Loading
Loading