Skip to content

An automated testing library for Mineflayer and Mineflayer plugins with CI/CD.

License

Notifications You must be signed in to change notification settings

u9g/mineflayer-test-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mineflayer-test-api

NPM version Build Status Discord Try it on gitpod

An automated testing library for Mineflayer and Mineflayer plugins with CI/CD.

Usage

In your project, create a folder called "test". In this folder, you can create as many test files as you want. Each of these will be iterated over and executed automatically. (Nested folders are allowed)

An example of a test script:

// Load the registerTest function
const { registerTest } = require('mineflayer-test-api')
const mineflayer = require('mineflayer')
const events = require('events')

// Register a new test with a name an an async test function
registerTest('run forward', async (server, startPosition) => {

  // Create your bot and have it join the server
  const bot = await server.createBot({
    makeOp: true,
    startPosition: startPosition
  })

  // Run our test
  bot.setControlState('sprint', true)
  bot.setControlState('forward', true)
  await bot.waitForTicks(20)

  // Validate the test results.
  if (bot.entity.position.distanceTo(startPosition) < 5) throw new Error('Bot move too little!')
  if (bot.entity.position.distanceTo(startPosition) > 15) throw new Error('Bot moved too far!')
})

In your CI file, simply run npm run mineflayer-test [mcVersion 1] [mcVersion 2] ... to run all test files.

About

An automated testing library for Mineflayer and Mineflayer plugins with CI/CD.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.3%
  • Dockerfile 2.7%