Generated by GPT-5-mini| nyc (software) | |
|---|---|
| Name | nyc |
| Developer | Istanbul Project |
| Released | 2012 |
| Programming language | JavaScript |
| Operating system | Cross-platform |
| Platform | Node.js |
| License | BSD-3-Clause |
nyc (software) nyc is a JavaScript code coverage tool for Node.js projects that integrates with testing frameworks and transpilers. It provides statement, branch, function, and line coverage metrics and generates reports suitable for continuous integration systems like Travis CI, Jenkins, and CircleCI. Originally developed as part of the Istanbul (software) ecosystem, nyc became widely used in npm-based workflows and GitHub-hosted repositories.
nyc operates as a command-line wrapper that instruments JavaScript code to collect coverage data during test runs with runners such as Mocha (JavaScript test framework), Jest (JavaScript testing framework), and AVA (software). It produces output in formats compatible with tools like lcov, Cobertura, and text-summary and integrates with services including Codecov and Coveralls. nyc supports modern JavaScript syntax by cooperating with transpilers and source map providers such as Babel and TypeScript.
nyc offers runtime instrumentation, on-the-fly source map support, and multiple report formats. It provides configuration via package.json fields and .nycrc files, allowing inclusion and exclusion patterns for files and directories, which aligns with conventions used by npm packages and Yarn (software). Coverage thresholds can be enforced to fail builds in Travis CI, GitHub Actions, and CircleCI pipelines. nyc also emits combined reports for monorepos managed with Lerna (software) or Yarn Workspaces.
nyc's architecture centers on the instrumentation engine derived from the Istanbul project and the runtime hook that intercepts module loading within Node.js's module system. It leverages source maps generated by Babel, TypeScript, CoffeeScript, and bundlers like Webpack and Rollup (software) to map coverage data back to original source files. The design emphasizes minimal intrusion by wrapping test runners and recording coverage into a centralized coverage map that can be serialized into formats consumed by CI tools such as Jenkins and Travis CI.
nyc is typically invoked via npm scripts or directly as a CLI tool. Common invocations include wrapping test commands with nyc before Mocha (JavaScript test framework) or Jest (JavaScript testing framework), and using flags to set reporter types or output directories. Configuration options mirror conventions used by npm and package.json and allow integration with linters like ESLint and formatters such as Prettier (software). nyc supports environment variables common in Unix-like shells and PowerShell for cross-platform CI scripting.
nyc integrates with test frameworks including Mocha (JavaScript test framework), Tape (software), Jest (JavaScript testing framework), and AVA (software), and with transpilers such as Babel, TypeScript, and CoffeeScript. It produces output consumable by reporting services like Codecov and Coveralls and CI systems like Travis CI, CircleCI, GitHub Actions, and Jenkins. Bundlers and task runners including Webpack, Rollup (software), and Gulp can be used in tandem with nyc to instrument bundled code. Integration with monorepo tools such as Lerna (software) and Nx (software) is common in large JavaScript organizations and projects hosted on GitHub or GitLab.
The development of nyc has occurred in public repositories on GitHub as part of the broader Istanbul community, attracting contributors who also participate in projects like Istanbul (software), Babel, and TypeScript. Contributions follow common open-source workflows using GitHub Flow and pull requests, with continuous integration provided by Travis CI or GitHub Actions. Bug reports and feature requests are tracked alongside discussions that reference related ecosystem projects such as npm, Yarn (software), and Node.js package maintainers.
nyc achieved adoption across many npm-based projects and is cited in tutorials and guides maintained by organizations that use Node.js in production, including companies that publish open-source tooling on GitHub. It is frequently recommended in articles comparing coverage tools alongside Istanbul (software), Jest (JavaScript testing framework), and other ecosystem utilities. nyc's compatibility with CI services like Travis CI, CircleCI, and GitHub Actions contributed to its uptake in continuous integration workflows for JavaScript and TypeScript projects.
Category:JavaScript software