@minecraft/server-gametest
Module
The @minecraft/server-gametest module provides scriptable APIs for scaffolding and testing content experiences in Minecraft.
Changelog
Manifest Details
{
"module_name": "@minecraft/server-gametest",
"version": "0.1.0"
}
Available Versions
1.0.0-beta
0.1.0
Enumerations
Classes
- FenceConnectivity
- GameTestSequence
- NavigationResult
- RegistrationBuilder
- SculkSpreader
- SimulatedPlayer
- Tags
- Test
Interfaces
Errors
Functions
register
register(testClassName: string, testName: string, testFunction: (arg: Test) => void): RegistrationBuilder
Registers a new GameTest function. This GameTest will become available in Minecraft via /gametest run [testClassName]:[testName].
Parameters
testClassName: string
Name of the class of tests this test should be a part of.
testName: string
Name of this specific test.
testFunction: (arg: Test) => void
Implementation of the test function.
Returns RegistrationBuilder - Returns a @minecraft/server-gametest.RegistrationBuilder object where additional options for this test can be specified via builder methods.
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Important
This function can't be called in read-only mode.
Examples
simpleMobTest.ts
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');
registerAsync
registerAsync(testClassName: string, testName: string, testFunction: (arg: Test) => Promise<void>): RegistrationBuilder
Registers a new GameTest function that is designed for asynchronous execution. This GameTest will become available in Minecraft via /gametest run [testClassName]:[testName].
Parameters
testClassName: string
Name of the class of tests this test should be a part of.
testName: string
Name of this specific test.
testFunction: (arg: Test) => Promise<void>
Implementation of the test function.
Returns RegistrationBuilder - Returns a @minecraft/server-gametest.RegistrationBuilder object where additional options for this test can be specified via builder methods.
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Important
This function can't be called in read-only mode.
Examples
simpleMobAsyncTest.ts
import * as gameTest from '@minecraft/server-gametest';
gameTest
.registerAsync('StarterTests', 'simpleMobTest', async (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');