Only show guides for your app
Write real tests with Node's built-in test runner and with pytest, run them before every push, and know exactly what "green" means — plus the honest truth that Falix doesn't run CI for you.
A test is a tiny program that checks your real program still works. Build the habit of running a handful before every push and you'll catch broken code on your own machine instead of in front of your users. The good news: both Node and Python ship with everything you need — Node has a built-in test runner, and Python pairs with pytest in one install.
| At a glance | |
|---|---|
| You need | Node or Python installed locally (Run your project locally first) |
| Plan | Any — you run tests on your machine, not a server |
| Time | Thirty minutes |
⚠️ Falix doesn't run your tests for you. There's no CI on the platform — a deploy copies files and starts your app, it never runs
npm testorpytest. So tests are only as useful as your habit of running them. Run them locally before you push. (If you want tests to run automatically on every push, that happens on GitHub, not Falix — see the CI note below.)
Node 18+ includes a test runner and assertion library — no dependency to install. Put your logic in one file and its tests in a *.test.js file beside it.
math.js — the code under test:
function add(a, b) {
return a + b;
}
module.exports = { add };
math.test.js — the tests:
const { test } = require('node:test');
const assert = require('node:assert');
const { add } = require('./math');
test('add sums two numbers', () => {
assert.strictEqual(add(2, 3), 5);
});
test('add handles negatives', () => {
assert.strictEqual(add(-1, 1), 0);
});
Run every *.test.js file in your project:
node --test
A passing run ends with a summary line — # pass 2 and # fail 0 — and exits with status 0. A failing assertion shows which test broke and what it expected. Add --watch (node --test --watch) to re-run automatically as you edit.
pytest is the standard Python testing tool. It's one dependency; add pytest to your requirements.txt (or pip install pytest). Name test files test_*.py and test functions test_* — pytest finds them for you.
math_utils.py:
def add(a, b):
return a + b
test_math_utils.py:
from math_utils import add
def test_add():
assert add(2, 3) == 5
def test_add_negatives():
assert add(-1, 1) == 0
Run it:
python -m pytest
A passing run prints 2 passed and exits 0. python -m pytest is the form to prefer — it works regardless of whether pytest's script is on your PATH (which matters if you ever run it on a server, where installed console scripts aren't on the PATH).
You don't need to test everything on day one. Start where a bug would hurt most and where testing is easy:
Skip trying to test things that need a live Discord connection or a running web request at first — those are harder and lower-value than testing the logic underneath them.
The point of a test is to catch a problem before it ships, so run tests at the moment right before pushing:
node --test / python -m pytest.git commit and git push.💡 Tip: Make it automatic with a pre-push Git hook: a script at
.git/hooks/pre-pushthat runs your tests and blocks the push if they fail. It turns "remember to test" into "can't forget to test".
Could you run tests on Falix — say, as a post-deploy command or a schedule? Technically the runtime executes them, but it's the wrong place: by the time a deploy runs, the code is already live. If you want tests to gate your code automatically, run them on GitHub with GitHub Actions before Falix ever pulls — see CI checks before Falix pulls. Falix's job is to run your app; the test gate belongs upstream.
Deliberately break a test — change the expected 5 to 6 — and re-run. The runner should report a failure and exit non-zero (# fail 1, or pytest's 1 failed). Change it back and it's green again. If your suite can turn red, it can protect you.
node --test finds nothing — your files aren't named *.test.js. Rename them or pass a path: node --test path/to/tests.test_ and functions with test_; check both.pytest: command not found — the installed script isn't on your PATH. Use python -m pytest, which always works.ModuleNotFoundError for your own file in a test — run pytest from the project root so the import path resolves, or add an __init__.py.