@bedrock-oss/minecraft-server-jest
v0.0.4
Published
Typed Jest mock for @minecraft/server
Downloads
56
Readme
minecraft-server-jest
A Jest preset and mock library for testing scripts that use the @minecraft/server API. This package provides typed mocks for a small portion of the Bedrock server module so you can write unit tests without needing a running game.
Installation
npm install --save-dev @bedrock-oss/minecraft-server-jestUsage
Add the preset to your Jest configuration. This automatically registers the mocks for @minecraft/server.
// jest.config.js
module.exports = {
preset: '@bedrock-oss/minecraft-server-jest',
};Run Jest as normal:
npx jestPhase checks emulate Bedrock's execution phases. They are enabled by default. Set MC_PHASE_CHECKS=false to disable them for an entire run.
Example
import { world } from '@minecraft/server';
test('hello world', () => {
system.run(() => {
world.sendMessage('hello');
});
});