feat(framework): server testing utils, transaction storage simplify, pathfinding tests (#384)
## Server Testing Utils - Add TestServer, TestClient, MockRoom for unit testing - Export testing utilities from @esengine/server/testing ## Transaction Storage (BREAKING) - Simplify RedisStorage/MongoStorage to factory pattern only - Remove DI client injection option - Add lazy connection and Symbol.asyncDispose support - Add 161 unit tests with full coverage ## Pathfinding Tests - Add 150 unit tests covering all components - BinaryHeap, Heuristics, AStarPathfinder, GridMap, NavMesh, PathSmoother ## Docs - Update storage.md for new factory pattern API
This commit is contained in:
37
packages/framework/server/src/testing/index.ts
Normal file
37
packages/framework/server/src/testing/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @zh 服务器测试工具
|
||||
* @en Server testing utilities
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { createTestServer, TestClient } from '@esengine/server/testing'
|
||||
*
|
||||
* describe('GameRoom', () => {
|
||||
* let env: TestEnvironment
|
||||
*
|
||||
* beforeEach(async () => {
|
||||
* env = await createTestEnv()
|
||||
* env.server.define('game', GameRoom)
|
||||
* })
|
||||
*
|
||||
* afterEach(async () => {
|
||||
* await env.cleanup()
|
||||
* })
|
||||
*
|
||||
* it('should join room', async () => {
|
||||
* const client = await env.createClient()
|
||||
* const result = await client.joinRoom('game')
|
||||
* expect(result.roomId).toBeDefined()
|
||||
* })
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
|
||||
export { TestClient, type TestClientOptions } from './TestClient.js'
|
||||
export {
|
||||
createTestServer,
|
||||
createTestEnv,
|
||||
type TestServerOptions,
|
||||
type TestEnvironment,
|
||||
} from './TestServer.js'
|
||||
export { MockRoom } from './MockRoom.js'
|
||||
Reference in New Issue
Block a user