prismarinejs / mineflayer-test-api Goto Github PK
View Code? Open in Web Editor NEWAn automated testing library for Mineflayer and Mineflayer plugins with CI/CD.
License: MIT License
An automated testing library for Mineflayer and Mineflayer plugins with CI/CD.
License: MIT License
Setting up a new test should be as simple as creating a new file within the test folder. Tests should be automatically loaded and executed from a single command within the CI pipeline.
A load that retrieves and runs all test files within a folder.
Manually loading and executing each test file.
N/A
Having all tests run on the main thread can heavily distort timing and cause lag. This has the potential to make tests fail because the CPU couldn't keep up with executing time-sensitive commands.
Each test should be moved to its own worker thread and executed in groups to prevent overlapping.
The only other practical alternative is running tests one at a time, but this would be extremely slow.
Since each test is fully self-contained and the server is a separate process, running each test on its own thread would have no memory issues.
When working with Mineflayer plugin development, having a complex yet repeatable environment is extremely useful for testing and performance evaluations. Being able to build a schematic from a file on the server is a good way to provide a complex situation to test against.
A simple function to load a schematic file and build it on the server.
Issuing lists of pre-defined /setblock
commands.
This feature request was mentioned in the original Issue thread for Mineflayer test API, here.
When defining tests, there's often a lot of overlap with the needed API on the server. It would be useful to not have to define these actions multiple times. Pushing common server API sets, such as maze generation or spawning mob groups, would be well suited to external plugins that could be loaded in one line of code.
In addition to the registerTest
function provided, also provide a loadPlugin
function that is called on a server when it is initially started in order to create their own utility test plugins that make it easier to write simple and repeatable tests.
Registering APIs manually within each test. But this is suboptimal and slow.
This behavior should work very closely with the bot.loadPlugin
behavior provided within Mineflayer. Loading a plugin once will register it for all tests.
mineflayer have some good cleanups as part of https://github.com/PrismarineJS/mineflayer/blob/master/test/externalTests/plugins/testCommon.js and https://github.com/PrismarineJS/mineflayer/blob/master/test/externalTest.js
it could be useful to have this here I think
If a test happens to stall, there is currently no way to skip the test and continue. This causes the CI to hang for an extended period of time.
Tests should automatically fail once if the test has not completed after a certain period of time. (Such as 1 minute) This time should be configurable.
Manually added test timeouts.
N/A
When showing the names of tests in the console, the test paths are generated incorrectly. For example, with a test file named myTest.js
containing the test Jump Forward
, the test name will be rendered as ../Jump Forward
. This is incorrect.
const { registerTest } = require('mineflayer-test-api')
registerTest('Jump Forward', async (server, startPos) => {
throw new Error('Failed!')
}
The correct test name should be shown as test/myTest.js/Jump Forward
N/A
During the event of an unexpected lag spike, certain server APIs may not fully finish executing before the promise returns. This leads to race conditions when the CI server is running slower than expected.
All server API calls should verify that the action has completed before returning. This would likely be done by adding listeners to the bot instance and waiting for the bot to receive the correct events indicated that the action has completed. This could be messages in chat for the case of becoming OP, or waitForChunksToLoad in the case of teleporting.
A simple alternative would be to increase the sleep time of each promise before returning, but this is only a bandaid solution and not a real fix. Plus, this would only increase the executing time of the events needlessly under normal circumstances.
Current Server API:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.