Skip to content

test: Add fast-check and vitest config infrastructure#30

Open
NAME-ASHWANIYADAV wants to merge 1 commit into
agones-dev:mainfrom
NAME-ASHWANIYADAV:test/property-testing-infra
Open

test: Add fast-check and vitest config infrastructure#30
NAME-ASHWANIYADAV wants to merge 1 commit into
agones-dev:mainfrom
NAME-ASHWANIYADAV:test/property-testing-infra

Conversation

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor

Type of change

  • 🐛 Bug fix
  • 🚀 New feature / enhancement
  • 📖 Documentation
  • 🧹 Refactoring / cleanup
  • ⚙️ CI / tooling
  • ⚠️ Breaking change

What this PR does

This PR introduces the testing infrastructure required for property-based testing in the Agones plugin.

The Agones plugin resource models (GameServer, Fleet, etc.) extend KubeObject from @kinvolk/headlamp-plugin/lib/k8s/cluster. This path is externalised by Headlamp at build time and does not physically exist in node_modules, causing Vitest to crash when trying to instantiate these models in tests.

To fix this, this PR:

  1. Adds fast-check as a devDependency.
  2. Creates src/__mocks__/kubeObject.ts as a minimal stand-in KubeObject.
  3. Adds vitest.config.mts which extends the upstream Headlamp vite config with a resolve alias, redirecting the externalised import to our mock.
  4. Updates the test script in package.json to use this custom vitest config.

This is a pure infrastructure PR. The actual property-based tests will follow in a subsequent PR.

Test plan

Automated checks

  • npm ci
  • npm run build
  • npm run tsc
  • npm run lint
  • npm run format -- --check
  • npm run test

Verified that the mock only affects the test environment and npm run build behaves exactly as before.

Notes for reviewers

This infrastructure matches the standard approach for testing Headlamp plugins that extend KubeObject. It does not conflict with pending PRs since the new config and mock files are completely new.

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

@illume will appreciate a review !!

Comment thread src/__mocks__/kubeObject.ts Outdated
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
@NAME-ASHWANIYADAV NAME-ASHWANIYADAV force-pushed the test/property-testing-infra branch from 4d94e7b to cf39ab9 Compare July 7, 2026 18:08

@lacroixthomas lacroixthomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM !
About the mock, we can still add things to it depending on the usage with other PRs 👌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants