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

test: replacce floss with vitest #2396

Open
wants to merge 13 commits into
base: dev/1.4
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@galacean/engine-physics-lite": "workspace:*",
"@galacean/engine-physics-physx": "workspace:*",
"dat.gui": "^0.7.9",
"vite": "^3.1.6",
"vite": "3.1.6",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider the implications of pinning the Vite version

The change from "^3.1.6" to "3.1.6" for the vite package pins it to an exact version. This ensures consistency across different environments but may prevent automatic updates for bug fixes or performance improvements.

Consider the following:

  1. Document the reason for pinning this specific version in a comment or commit message, if not already done.
  2. Evaluate if there are any known issues with newer patch versions of Vite 3.1.x that necessitate this pinning.
  3. Set up a process to periodically review and update this version to ensure you're not missing out on important updates.

If there's no specific reason to pin this exact version, you might want to keep the caret (^) to allow patch updates:

-    "vite": "3.1.6",
+    "vite": "^3.1.6",

This would allow automatic updates to patch versions (e.g., 3.1.7, 3.1.8) which typically include bug fixes and performance improvements without breaking changes.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"vite": "3.1.6",
"vite": "^3.1.6",

"sass": "^1.55.0"
}
}
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",
"pretest": "pnpm exec playwright install",
"test": "vitest",
"coverage": "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