screeps-typescript-starter icon indicating copy to clipboard operation
screeps-typescript-starter copied to clipboard

Using Object.defineProperty on prototypes causes the tests to fail to build

Open FutureAstroMiner opened this issue 3 years ago • 2 comments

Using Object.defineProperty like:

Object.defineProperty(Creep.prototype, 'boosts', {
	get() {
		if (!this._boosts) {
			this._boosts = _.compact(_.unique(_.map(this.body as BodyPartDefinition[], bodyPart => bodyPart.boost)));
		}
		return this._boosts;
	},
	configurable: true,
});

and importing this into the main file causes the test to fail to build with a reference error ReferenceError: Creep is not defined

FutureAstroMiner avatar Apr 20 '21 20:04 FutureAstroMiner

I have been looking around for a solution to this issue but I can't find one.

The alternative is to use Jest as this issue seams to have been fixed by eduter in screeps-typescript-jest-starter but integration tests are not available.

Should Object.defineProperty be done in a different way?

FutureAstroMiner avatar Aug 07 '21 20:08 FutureAstroMiner

Try again with

enumerable: false,

madrang avatar Jun 07 '22 03:06 madrang