generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 328
docs: add challenge files template #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ojeytonwilliams
merged 21 commits into
freeCodeCamp:main
from
majestic-owl448:docs/challenge-md-templates
Mar 13, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a0d62a8
docs: add MD file templates to workshops, labs, quizzes, and reviews …
majestic-owl448 6ccb4df
docs: add demoType to workshop step template
majestic-owl448 33fc755
docs: clarify demoType is only for HTML-based challenges with demo
majestic-owl448 c8562ea
docs: add hooks section to labs and workshops guides
majestic-owl448 2ebea48
docs: clarify hook execution order and DOM vs non-DOM differences
majestic-owl448 07db53d
docs: clean up hooks execution order section
majestic-owl448 5d52088
docs: fix fcc-editable-region markers mangled by prettier
majestic-owl448 764b382
Apply suggestions from code review
majestic-owl448 d616511
Apply suggestions from code review
majestic-owl448 fb7995f
Apply suggestions from code review
majestic-owl448 0e08006
style: fix trailing whitespace flagged by prettier
majestic-owl448 862c7fb
Apply suggestions from code review
majestic-owl448 5ce4b9d
address review comments
majestic-owl448 dad1a8b
move execution order to shared partial and genericize language
majestic-owl448 2f8cac8
docs: add Proposing a Pull Request section to labs guide
majestic-owl448 e60fc4e
docs: add HTML/CSS/JS multi-file interactive editor example to review…
majestic-owl448 66bbe4e
Apply suggestions from code review
majestic-owl448 40e4bab
Apply suggestions from code review
majestic-owl448 5e980d3
docs: clarify before-all scoping in non-DOM challenges
majestic-owl448 529d790
Apply suggestions from code review
majestic-owl448 82f51df
fix: remove trailing whitespace in hooks-shared
majestic-owl448 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| Four hooks are available: | ||
|
|
||
| | Hook | When it runs | | ||
| | ----------------- | ------------------------------------------------------------------------------------------- | | ||
| | `--before-all--` | Once, before any test runs | | ||
| | `--before-each--` | Before each individual test | | ||
| | `--after-each--` | After each individual test (in a `finally` block, so it always runs even if the test fails) | | ||
| | `--after-all--` | Once, after all tests have finished | | ||
|
|
||
| **Execution order:** | ||
|
|
||
| For challenges that have an HTML file, `--before-all--` is injected as a `<script>` tag into the sandboxed iframe _before_ the user's HTML is parsed, so it runs before user code. It has full access to DOM APIs and global test helpers like `__FakeTimers` and `$` (jQuery). The user's code then renders into the page, and each test runs against the live DOM: | ||
|
|
||
| ``` | ||
| 1. --before-all-- | ||
|
|
||
| 2. user code (evaluated once) | ||
|
|
||
| 3. (for each test): --before-each-- → test → --after-each-- | ||
|
|
||
| 4.--after-all-- | ||
| ``` | ||
|
|
||
| For challenges that do not have an HTML file, `--before-all--` runs once before any test. However, because user code is re-evaluated as part of each individual test (concatenated with `--before-each--` and the test in a single `eval`), variables declared in `--before-all--` will not be in scope during tests. To share state across tests, assign to the global object directly (e.g. `globalThis.x = 1` instead of `let x = 1`): | ||
|
|
||
| ``` | ||
| 1. --before-all-- | ||
|
|
||
| 2. (for each test): --before-each-- → user code → test → --after-each-- | ||
|
|
||
| 3. --after-all-- | ||
| ``` | ||
|
|
||
| **Syntax:** | ||
|
|
||
| Hooks use the same `# --hook-name--` heading syntax as other sections. Each hook must contain exactly one code block. Hooks are placed after `--description--` and before `--hints--`: | ||
|
|
||
| ````md | ||
| # --description-- | ||
|
|
||
| ... | ||
|
|
||
| # --before-all-- | ||
|
|
||
| ```js | ||
| // Runs once before any test. Set up shared state here. | ||
| let clock = __FakeTimers.install(); | ||
| ``` | ||
|
|
||
| # --before-each-- | ||
|
|
||
| ```js | ||
| // Runs before each test. | ||
| ``` | ||
|
|
||
| # --after-each-- | ||
|
|
||
| ```js | ||
| // Runs after each test, even if it fails. | ||
| ``` | ||
|
|
||
| # --after-all-- | ||
|
|
||
| ```js | ||
| // Runs once after all tests. Clean up here. | ||
| clock.uninstall(); | ||
| ``` | ||
|
|
||
| # --hints-- | ||
|
|
||
| ... | ||
| ```` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.