【发布时间】:2021-01-17 00:00:16
【问题描述】:
我正在尝试为来自 lance-gg 的 Renderer 子类编写单元测试
// test/client.js
const lance = require('lance-gg');
console.log(lance);
{
GameEngine: [Function: GameEngine],
GameWorld: [Function: GameWorld],
P2PhysicsEngine: [Function: P2PhysicsEngine],
SimplePhysicsEngine: [Function: SimplePhysicsEngine],
BaseTypes: [Function: BaseTypes] {
TYPES: {
FLOAT32: 'FLOAT32',
INT32: 'INT32',
INT16: 'INT16',
INT8: 'INT8',
UINT8: 'UINT8',
STRING: 'STRING',
CLASSINSTANCE: 'CLASSINSTANCE',
LIST: 'LIST'
}
},
TwoVector: [Function: TwoVector],
DynamicObject: [Function: DynamicObject],
PhysicalObject2D: [Function: PhysicalObject2D],
PhysicalObject3D: [Function: PhysicalObject3D],
ServerEngine: [Function: ServerEngine],
Lib: { Trace: [Function: Trace] }
}
./node_modules/.bin/mocha --require @babel/register ./test/client.js
但是,lance.Renderer 解析为未定义,这让我怀疑 lance 是从服务器导出而不是此处定义的客户端导出构建的:https://github.com/lance-gg/lance/blob/911b60bdb5b887aa281e7c968506028797616132/rollup.config.js
这是一个现有测试的示例,它似乎可以正确地将客户端代码编译到测试中:https://github.com/lance-gg/lance/blob/master/test/EndToEnd/multiplayer.js
我的问题是,require('lance-gg') 如何知道是导入客户端还是服务器端
如何从客户端导出编译测试?
【问题讨论】:
标签: javascript lance