Skip to main content

Function: register()

register(testClassName, testName, testFunction): RegistrationBuilder

Parameters

ParameterTypeDescription
testClassNamestringName of the class of tests this test should be a part of.
testNamestringName of this specific test.
testFunction(arg) => voidImplementation of the test function.

Returns

RegistrationBuilder

Returns a RegistrationBuilder object where additional options for this test can be specified via builder methods.

Remarks

Registers a new GameTest function. This GameTest will become available in Minecraft via /gametest run [testClassName]:[testName].

This function can't be called in read-only mode.

Example

import * as gameTest from '@minecraft/server-gametest';

gameTest
.register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => {
const attackerId = 'fox';
const victimId = 'chicken';

test.spawn(attackerId, { x: 5, y: 2, z: 5 });
test.spawn(victimId, { x: 2, y: 2, z: 2 });

test.assertEntityPresentInArea(victimId, true);

test.succeedWhen(() => {
test.assertEntityPresentInArea(victimId, false);
});
})
.maxTicks(400)
.structureName('gametests:mediumglass');