Test tracks
Test track sandboxes by running simulated plays
Before you begin
This guide explains how to test a track to ensure your content is free from errors. You need the following to test tracks:
Background
The instruqt track test
command simulates a user starting and completing a track. When you run this command, Instruqt starts a new instance of your track and simulates a learner going through the track by executing all challenge lifecycle scripts.
In the test, Instruqt deploys an instance of the track's sandbox (and runs the track setup scripts) and performs the following steps for each challenge:
Run the challenge setup script
Run check script, expecting failure.
Run solve script, to mimic what the user would do.
Run check script again, expecting success.
By running these steps, you achieve the following:
Mimic the learner's behavior.
Validate that the track starts properly.
Validate that the challenge life cycle scripts (
setup
,check
andsolve
) have been implemented correctly.
The test stops when one of the steps fails or when all steps have been completed successfully.
Test a track
Tracks can only be tested using the Instruqt CLI.
In a track's directory, run the following command:
↳ Example output:
Skip the checking steps
Add the --skip-fail-check
flag to the instruqt track test
command to skip the first check attempt and go straight to the solve script.
The "Running check" steps will fail if you do not have check scripts present in your track.
Keep tracks running after testing
When the test has finished, it will automatically stop the track and delete the sandbox. If you would like to keep it running afterward, add the --keep-running
flag to the instruqt track test
command. This is useful when you debug a script issue and want to inspect the environment after the test has finished. If you are running the test with your credentials, you can go to play.instruqt.com and continue with the track where the test finished.
Test in CI/CD pipelines
Set authentication
To run tests from a CI/CD system like GitHub actions, you must authenticate with an Instruqt API token. To do this, create an API token. Once you have your API token, create an environment variable named INSTRUQT_TOKEN
with the token value in your CI/CD system.
Docker Image
Many CI/CD systems support running commands on containers as part of the build/test process. Instruqt provides a Docker Container Image with the current version of the Instruqt CLI pre-installed. Use this image in your CI/CD test pipelines to access the Instruqt CLI easily.
Last updated