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: the built-in test runner
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.
Python: pytest
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).
What to test first
You don't need to test everything on day one. Start where a bug would hurt most and where testing is easy:
- Pure logic — functions that take input and return output (a price calculator, a permission check, a text parser). These are the easiest to test and the most valuable.
- The bug you just fixed — write a test that fails on the old behaviour and passes on the fix. Now it can never silently come back.
- Edge cases — empty input, zero, negative numbers, missing fields.
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.
Wire it into your workflow
The point of a test is to catch a problem before it ships, so run tests at the moment right before pushing:
- Edit and run your app locally.
node --test/python -m pytest.- Green?
git commitandgit push. - Red? Fix it — you just saved yourself a broken deploy.
💡 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".
The CI note, honestly
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.
Verify it works
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.
Troubleshooting
node --testfinds nothing — your files aren't named*.test.js. Rename them or pass a path:node --test path/to/tests.- pytest "collected 0 items" — files must start with
test_and functions withtest_; check both. pytest: command not found— the installed script isn't on your PATH. Usepython -m pytest, which always works.ModuleNotFoundErrorfor your own file in a test — run pytest from the project root so the import path resolves, or add an__init__.py.
Next steps
- Run your project locally first
- CI checks before Falix pulls
- The official docs go far beyond this: Node's test runner at nodejs.org and pytest at docs.pytest.org