ioBuster Framework Guide
What is ioBuster?
ioBuster is a tool for testing using scripts written in JavaScript. It's different from popular JavaScript runtimes like Node.js or Deno. What makes ioBuster special is that it has its own built-in libraries and global variables.
Starting with ioBuster
How to Get Sample Tests
ioBuster gives you sample tests to try. To get these tests:
iobc run config sample-scripts
After you do this, a folder named sample_tests will show up. This folder has
the sample tests.
How to Use Tests
Running a Test
When you're ready, you can run a sample test. Here's how:
Coordinator # test run all sample_tests/test.js
What is a Workspace?
In ioBuster, the word "Workspace" is important. When you say test run, the Workspace is the main folder of the test. If you type test run all main/tests/test.js, then main becomes the Workspace. It's where your test starts.
Paths in ioBuster
Let's imagine your folder structure looks like this:
main/
├── utils/
│ └── helper.js
└── tests/
└── sampleTest.js
ioBuster uses two ways to find and use scripts:
-
Relative Path: Tells ioBuster where the script is based on where you are now. If you're inside the
testsfolder and want to use thehelper.js, you would say:importScript('../utils/helper.js'). -
Absolute Path: This starts from the
Workspace(remember, in our case it'smain). To usehelper.js, you'd say:importScript('/utils/helper.js').
Both runScript and importScript understand these paths.
How to Use a Script
Using importScript
importScript lets you use a script in your current one. If you use the same
script two times with importScript, it runs only once.
Example:
importScript('utils/helper.js')
This means "I want to use helper.js from the utils folder."
Using runScript
runScript lets you run a script. It will run the script every time you use
runScript.
Example:
runScript('tests/sampleTest.js')
This means "I want to run sampleTest.js from the tests folder."