Challenge - 5 Problems
Automated Testing Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Git hook command?
You have a
If the tests fail, what will be the output of
pre-push Git hook script that runs tests before pushing. The script contains:#!/bin/sh npm test
If the tests fail, what will be the output of
git push?Git
#!/bin/sh npm test
Attempts:
2 left
💡 Hint
Git hooks can stop push if the script exits with an error.
✗ Incorrect
The pre-push hook runs before pushing. If
npm test fails (non-zero exit), the push is stopped and test errors are shown.🧠 Conceptual
intermediate1:30remaining
Why use automated tests on push in Git workflows?
Which of these is the main reason to run automated tests on every push?
Attempts:
2 left
💡 Hint
Think about preventing broken code from entering shared branches.
✗ Incorrect
Running tests on push helps catch bugs early and keeps the shared codebase stable.
❓ Configuration
advanced1:30remaining
Which Git hook file should you create to run tests automatically before pushing?
You want to run a test script automatically every time you push code. Which file should you create or edit inside the
.git/hooks directory?Attempts:
2 left
💡 Hint
The hook runs right before pushing to remote.
✗ Incorrect
The
pre-push hook runs before pushing and can block the push if tests fail.❓ Troubleshoot
advanced2:00remaining
Why does my pre-push hook not stop the push even if tests fail?
You wrote a
pre-push hook script to run tests, but even when tests fail, the push still succeeds. What is the most likely cause?Attempts:
2 left
💡 Hint
Git stops push only if the hook exits with an error code.
✗ Incorrect
If the script always exits with zero, Git assumes success and pushes regardless of test results.
🔀 Workflow
expert2:30remaining
Order the steps in a Git workflow with automated testing on push
Arrange these steps in the correct order when using automated tests triggered by a Git pre-push hook.
Attempts:
2 left
💡 Hint
Think about the natural flow from coding to pushing with tests in between.
✗ Incorrect
First code is written, then Git triggers pre-push hook, which runs tests, and if tests pass, push proceeds.