CodeVetter · Repo Unpack · Testing signals
prettier/prettier
Jest 30 with jest-light-runner drives four suites: snapshot format tests, CLI/API integration tests, unit tests, and dts tests. Format tests are directory fixtures plus runFormatTest, which implicitly adds extra JS parsers and, under FULL_TEST=1, AST-compare, second-format, EOL, and BOM checks. Production tests install dist/prettier and also run standalone and browser (Puppeteer) matrices. Unit tests are skipped in production; integration tests are skipped in standalone/browser.
- jest.config.js testMatch: tests/format/**/format.test.js, tests/integration/__tests__/**/*.js, tests/unit/**/*.js, tests/dts/unit/**/*.js. Runner is jest-light-runner (child-process unless ENABLE_CODE_COVERAGE). Snapshot serializers: jest-snapshot-serializer-raw and -ansi.
- runFormatTest(import.meta, parsers, options) is the format-test DSL. getParsers implicitly adds acorn/espree/meriyah/oxc/yuku when babel is listed under tests/format/js|jsx; babel-ts/oxc-ts/yuku-ts when typescript is listed; hermes when flow is listed; __babel_estree when babel is listed.
- test-format.js snapshots eolVisualizedOutput via createSnapshot; expectFail directories use toThrowErrorMatchingSnapshot. Additional FULL_TEST checks are described in CONTRIBUTING.md (compare AST, second format, CRLF/CR, BOM) and implemented under tests/config/format-test/.
- tests/format is partitioned by language (js, jsx, typescript, flow, css, scss, less, html, vue, angular, markdown, mdx, yaml, graphql, handlebars, json, mjml, lwc, misc) with per-directory __snapshots__/format.test.js.snap. Flow’s tests/format/flow/flow-repo/ is synced via scripts/sync-flow-tests.cjs, not edited by hand.
- Integration tests cover CLI behaviors (check, write, cache, patterns, ignore, stdin, plugins, config-resolution, experimental-cli, node-version-check, help-options) with snapshot files under tests/integration/__tests__/__snapshots__/.
- Unit tests (tests/unit/) cover doc-printer, doc-builders, ast-path, visitor-keys, config-loader, resolve-parser, builtin-plugins, editorconfig-to-prettier, massage-ast; they are ignored when NODE_ENV=production. Bundle tests are ignored in development.
- Production Jest installs the built package via tests/config/install-prettier.js into a temp node_modules/prettier (unless SKIP_PRODUCTION_INSTALL); TEST_STANDALONE and TEST_RUNTIME=browser remap the entry and skip tests/integration/. Browser tests skip several plugin/front-matter format tests.
- package.json test scripts: test=jest; test:dev-package=INSTALL_PACKAGE=1; test:production=NODE_ENV=production; test:production-standalone=TEST_STANDALONE=1; test:production:browser with TEST_RUNTIME_BROWSER chrome|firefox and TEST_BUNDLE_FORMAT umd. Coverage via c8 include src/** and bin/**.
- Lint CI also runs yarn lint:format-test (scripts/format-test-lint.js), prettier check on docs with PRETTIER_DEBUG=true so embedded format errors throw, yarn lint:deps, tsc, knip (separate lint:knip script), and codecov upload of coverage/lcov.info.
- Release-script tests live in scripts/release/tests/; dts tests in tests/dts/unit/run.js (skipped on Node <=14). Dummy plugins under tests/config/prettier-plugins/ exercise embed/async printer/missing comments.
- Prod CLI job runs dist/prettier on Node v0.10.48 solely to assert the engines check message 'Prettier requires at least version 14 of Node.js' — the production engine floor advertised by that job is 14, while package.json engines.node is >=22 for this source tree.