diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 551388fcc..665061af5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -48,7 +48,7 @@ jobs:
- { node: '16', postgres: &stable_postgres '18' }
- { node: '18', postgres: *stable_postgres }
- { node: '20', postgres: *stable_postgres }
- - { node: '22', postgres: *stable_postgres }
+ - { node: '22', postgres: *stable_postgres, coverage: true }
- { node: '24', postgres: *stable_postgres }
# Latest Node.js version tested against multiple PostgreSQL versions
- { node: &latest_node '26', postgres: '13' }
@@ -92,4 +92,8 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn
- run: yarn install --frozen-lockfile
- - run: yarn test
+ - run: yarn ${{ matrix.coverage && 'coverage' || 'test' }}
+ - uses: coverallsapp/github-action@v2
+ if: ${{ matrix.coverage }}
+ with:
+ file: coverage/lcov.info
diff --git a/.gitignore b/.gitignore
index c6d5700ae..aecc1454f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,6 @@ dist
.vscode/
manually-test-on-heroku.js
tsconfig.tsbuildinfo
+
+coverage/
+.nyc_output/
diff --git a/.nycrc b/.nycrc
new file mode 100644
index 000000000..6e1d2f67e
--- /dev/null
+++ b/.nycrc
@@ -0,0 +1,14 @@
+{
+ "all": true,
+ "include": ["packages/*/index.js", "packages/*/lib/**", "packages/*/src/**", "packages/*/dist/**"],
+ "exclude": [
+ "**/*.test.*",
+ "**/*.d.ts",
+ "**/test/**",
+ "**/testing/**",
+ "packages/pg-protocol/src/b.ts",
+ "packages/pg-esm-test/**",
+ "packages/pg-bundler-test/**"
+ ],
+ "reporter": ["text", "lcov"]
+}
diff --git a/README.md b/README.md
index ecd94e792..2d7b3b5a1 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# node-postgres

+[](https://coveralls.io/github/brianc/node-postgres?branch=master)
diff --git a/package.json b/package.json
index e30454007..59489327b 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,8 @@
"docs:build": "cd docs && yarn build",
"docs:start": "cd docs && yarn dev",
"pretest": "yarn build",
+ "precoverage": "yarn build",
+ "coverage": "nyc --silent lerna exec --concurrency 1 --ignore pg-connection-string -- yarn test && nyc --no-clean yarn workspace pg-connection-string mocha",
"prepublish": "yarn build",
"lint": "eslint --cache 'packages/**/*.{js,ts,tsx}'"
},
@@ -29,6 +31,7 @@
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-prettier": "^5.1.2",
"lerna": "^3.19.0",
+ "nyc": "^15",
"prettier": "3.0.3",
"typescript": "^6.0.3"
},