eduter / screeps-jest

Helper functions and environment for unit testing your Screeps code with Jest.
14 stars 4 forks source link

Mock constructors out-of-the-box, so that extending prototype doesn't throw #2

Closed eduter closed 4 years ago

eduter commented 4 years ago

Something like this, in TestEnvironment.ts, should be enough:

[
  'ConstructionSite',
  'Creep',
  'Flag',
  'Mineral',
  'Nuke',
  'OwnedStructure',
  'Resource',
  'Room',
  'RoomObject',
  'RoomVisual',
  'Source',
  'Structure',
  'StructureContainer',
  'StructureController',
  'StructureExtension',
  'StructureExtractor',
  'StructureFactory',
  'StructureInvaderCore',
  'StructureLab',
  'StructureLink',
  'StructureKeeperLair',
  'StructureNuker',
  'StructureObserver',
  'StructurePortal',
  'StructurePowerBank',
  'StructurePowerSpawn',
  'StructureRampart',
  'StructureRoad',
  'StructureSpawn',
  'StructureStorage',
  'StructureTerminal',
  'StructureTower',
  'StructureWall',
  'Spawning',
  'Tombstone'
].forEach(className => {
  this.global[className] = { prototype: {} };
});
github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: