Tutorial: Nx Monorepo
What This Tutorial Will Cover
Section titled “What This Tutorial Will Cover”When Node.js support lands, this tutorial will walk through:
- Setting up a new Nx workspace with two packages: a Node.js API library and a shared utilities library
- Configuring Jest with
json-summarycoverage reporter per package - Running
nolapse initonce per package with its own baseline andnolapse.yaml - Running a per-package coverage check with
nolapse run --repo packages/api - Adding a GitHub Actions matrix job that runs nolapse for each package in parallel
- Setting different thresholds per package to account for varying coverage maturity
Expected Workspace Structure
Section titled “Expected Workspace Structure”my-nx-workspace/├── packages/│ ├── api/│ │ ├── src/│ │ ├── .audit/coverage/baseline.md│ │ ├── nolapse.yaml│ │ └── project.json│ └── utils/│ ├── src/│ ├── .audit/coverage/baseline.md│ ├── nolapse.yaml│ └── project.json├── nx.json└── .github/ └── workflows/ └── coverage.ymlExpected Commands (Once Available)
Section titled “Expected Commands (Once Available)”Initialise each package
Section titled “Initialise each package”nolapse init --repo packages/api --lang nodejsnolapse init --repo packages/utils --lang nodejsCheck each package
Section titled “Check each package”nolapse run --repo packages/api --lang nodejsnolapse run --repo packages/utils --lang nodejsGitHub Actions matrix workflow
Section titled “GitHub Actions matrix workflow”name: Coverage check
on: pull_request:
jobs: coverage: runs-on: ubuntu-latest strategy: matrix: package: [packages/api, packages/utils] steps: - uses: actions/checkout@v4 with: fetch-depth: 0
- name: Set up Node uses: actions/setup-node@v4 with: node-version: "20"
- name: Install dependencies run: npm ci
- name: Run nolapse — ${{ matrix.package }} uses: nolapse/nolapse-action@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} repo: ${{ matrix.package }} lang: nodejs warn-threshold: "0.5" fail-threshold: "1.0"Per-Package Thresholds
Section titled “Per-Package Thresholds”Each package’s nolapse.yaml is independent, so you can set different thresholds:
# packages/api/nolapse.yaml — critical path, tight thresholdlang: nodejswarn_threshold: 0.1fail_threshold: 0.5# packages/utils/nolapse.yaml — utility code, looser thresholdlang: nodejswarn_threshold: 1.0fail_threshold: 2.0Nx-Specific Considerations
Section titled “Nx-Specific Considerations”- Nx’s
nx affectedcommand can determine which packages changed in a PR. A future integration may allow nolapse to skip unchanged packages automatically, reducing CI time. - Each package’s baseline is entirely independent — adding a new package to the workspace does not affect existing baselines.
- The Nx cache does not interfere with nolapse’s coverage measurement because nolapse invokes the test runner fresh each time.
Get Notified
Section titled “Get Notified”Watch the nolapse changelog for the Node.js runner release. Once available, this tutorial will be updated with full working commands and example output.
See Also
Section titled “See Also”- Monorepo Setup — the general monorepo guide (works today for Go and Python)
- Multi-Language Projects — mixing language components
- Tutorial: Go Microservice — a fully working tutorial available today