You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository powers the GitHub Docs site (docs.github.com). It contains both the Next.js application code (TypeScript) and the documentation content (Markdown).
4
+
5
+
## Instruction files
6
+
7
+
Read the relevant instruction files in `.github/instructions/` before making changes:
8
+
9
+
***`all.instructions.md`** — General project guidelines, PR conventions, and how to access docs.github.com content programmatically. Applies to all files.
10
+
***`code.instructions.md`** — TypeScript/JavaScript coding standards, test commands (per-suite with environment variables), and validation steps. Read this before any code change.
11
+
***`content.instructions.md`** — Markdown content conventions, Liquid variable usage, reusables, and linking with `[AUTOTITLE]`. Read this before any content change.
12
+
***`style-guide-summary.instructions.md`** — Condensed docs style guide covering voice, headers, lists, alerts, and formatting. Read this before any content change.
13
+
14
+
## Key rules
15
+
16
+
* All new code must be TypeScript (not JavaScript).
17
+
* Use `@/` absolute imports (e.g., `import getRedirect from '@/redirects/lib/get-redirect'`).
18
+
* Do not run `npm test` without a path argument — always target a specific suite.
19
+
* Run `npm run build` before running tests.
20
+
* Do not commit to `main`. Create a branch and open a draft PR.
21
+
* Use Liquid variables for product names — never hardcode them. Check `data/variables/`.
22
+
* Use `[AUTOTITLE](/path/to/article)` for internal links — never hardcode article titles.
Copy file name to clipboardExpand all lines: .github/instructions/code.instructions.md
+45-5Lines changed: 45 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,13 +24,53 @@ For code reviews, follow guidelines, tests, and validate instructions. For creat
24
24
25
25
We use `vitest` to write unit tests. Tests live in their own files in the `tests` subdirectory of a source (src) directory, e.g. `src/search/tests/api-ai-search.ts`. For integration tests, we can use the mock server in `src/tests/mocks/start-mock-server.ts` to mock external requests. For UI rendering tests, we use `playwright` and write tests in `src/fixtures/tests/playwright-rendering.spec.ts`
26
26
27
-
-`npm run test`: For all unit tests
28
-
- You can pass specific paths, e.g. `npm run test -- src/search/tests/ai-search-proxy`
29
-
- You can add `--silent=false` to include `console.log` debugging.
30
-
-`npm run build && npm run playwright-test -- playwright-rendering`: You need to build for changes outside of the test to be picked up. We use playwright for all rendering and end-to-end tests
27
+
**Important: Do NOT run `npm test` without a path argument.** Tests must be run per-suite because different suites require different environment variables. Running all tests at once will produce many false failures.
28
+
29
+
**Important: Run `npm run build` before running tests.** Many test suites depend on Next.js build artifacts. Without a build, tests may fail with `Could not find a production build` or other confusing errors.
30
+
31
+
### Running tests by suite
32
+
33
+
Always target the specific suite for the code you changed:
34
+
35
+
```shell
36
+
npm test -- src/<suite-name>/tests/
37
+
```
38
+
39
+
For example: `npm test -- src/search/tests/` or `npm test -- src/versions/tests/`
40
+
41
+
You can also target a single file: `npm test -- src/search/tests/ai-search-proxy.ts`
42
+
43
+
Add `--silent=false` to include `console.log` debugging output.
44
+
45
+
### Suites that require environment variables
46
+
47
+
Some test suites depend on fixture content or external services. These suites have dedicated npm scripts in `package.json` that set the required environment variables automatically:
48
+
49
+
```shell
50
+
npm run test:article-api
51
+
npm run test:changelogs
52
+
npm run test:fixtures
53
+
npm run test:landings
54
+
npm run test:languages # requires Elasticsearch running
55
+
npm run test:search # requires Elasticsearch running
56
+
```
57
+
58
+
For the `content-linter` suite, you can optionally scope linting to changed files by setting `DIFF_FILES` (space-separated list) or `DIFF_FILE` (path to a text file containing a space-separated list of changed files). Without these, the linter runs against all content:
59
+
60
+
```shell
61
+
DIFF_FILES="content/foo.md content/bar.md" npm test -- src/content-linter/tests/
62
+
```
63
+
64
+
All other suites (e.g., `versions`, `redirects`, `rest`, `frame`, `content-render`, `graphql`, etc.) can be run without special environment variables.
65
+
66
+
### Playwright (rendering and end-to-end tests)
67
+
68
+
-`npm run build && npm run playwright-test -- playwright-rendering`: You need to build for changes outside of the test to be picked up. We use playwright for all rendering and end-to-end tests.
31
69
- You can add `--ui` to keep open `localhost:4000` which can be viewed in a simple browser for debugging UI state.
70
+
71
+
### Development server
72
+
32
73
-`npm run dev` to start the development server on `localhost:4000`.
33
-
-`ROOT=src/fixtures/fixtures TRANSLATIONS_FIXTURE_ROOT=src/fixtures/fixtures/translations vitest src/fixtures/tests` for tests that involve fixtures.
0 commit comments