Your first GitHub Actions workflow. This one runs the JavaScript tests automatically whenever code is pushed or a pull request is opened.
- Creating a workflow YAML file
- Triggering on push and pull_request events
- Setting up Node.js in a runner
- Running tests with Node's built-in test runner
Copy the workflow file into your repo:
mkdir -p .github/workflows
cp lessons/01-frontend-tests/test.yml .github/workflows/test-frontend.ymlCommit and push. That's it.
The workflow does three things:
- Checks out your code
- Sets up Node.js 20
- Runs
node --test tests/test_logic.js
The tests cover the game's core logic: collision detection, level progression, spawn rates, and item selection. If any test fails, the workflow fails and you'll see a red X on the commit or PR.
- Copy the workflow file as shown above
- Push to GitHub
- Open the Actions tab in your repo to watch it run
- Try breaking a function in
app/static/logic.json a branch and opening a PR. You'll see the check fail.