| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| applyTo | src/**,.github/**,config/**,.devcontainer/**,**Dockerfile,package*.json |
|---|
For code reviews and for creating or updating pull requests, follow the Guidelines, Tests, and Validate sections below.
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
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.
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.
Always target the specific suite for the code you changed:
npm test -- src/<suite-name>/tests/For example: npm test -- src/search/tests/ or npm test -- src/versions/tests/
You can also target a single file: npm test -- src/search/tests/ai-search-proxy.ts
Add --silent=false to include console.log debugging output.
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:
npm run test:article-api
npm run test:fixtures
npm run test:landings
npm run test:languages # requires Elasticsearch running
npm run test:search # requires Elasticsearch runningFor 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:
DIFF_FILES="content/foo.md content/bar.md" npm test -- src/content-linter/tests/All other suites (e.g., versions, redirects, rest, frame, content-render, graphql, etc.) can be run without special environment variables.
Run the following commands to validate your changes:
Use createLogger from @/observability/logger instead of console.log in server-side code.
import { createLogger } from "@/observability/logger";
const logger = createLogger(import.meta.url);
logger.debug("Detailed tracing");
logger.info("Normal event", { userId });
logger.warn("Recoverable issue");
logger.error("Failure", { error });| Back | FazBrowse Home | New Git URL |