Skip to content

Commit

Permalink
test(next-drupal): add tooling to test code coverage
Browse files Browse the repository at this point in the history
Fixes #609
  • Loading branch information
JohnAlbin committed Nov 22, 2023
1 parent 22d5742 commit 399a64a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
23 changes: 0 additions & 23 deletions jest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"sync:starters": "./scripts/sync-starters.sh \"starters/*\"",
"seed": "NUM_NODES=200 node ./scripts/seed",
"cy:open": "turbo run cy:open --parallel",
"test": "jest",
"test": "yarn workspace next-drupal test && yarn workspace next-drupal-query test",
"pretest": "yarn format:check && yarn lint",
"test:e2e": "turbo run test:e2e --parallel",
"test:e2e:ci": "turbo run test:e2e:ci --parallel"
Expand Down
24 changes: 24 additions & 0 deletions packages/next-drupal-query/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest/presets/js-with-ts",
testEnvironment: "node",
setupFiles: ["dotenv/config"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
testMatch: ["**/tests/**/*.test.{ts,tsx}"],
globals: {
"ts-jest": {
isolatedModules: true,
},
},
coverageProvider: "v8",
collectCoverage: true,
collectCoverageFrom: ["./src/**"],
coverageThreshold: {
global: {
statements: 85.11,
branches: 58,
functions: 70,
lines: 85.11,
},
},
}
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/next-drupal-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"prepare": "microbundle --no-compress --jsx React.createElement --format modern,cjs",
"dev": "microbundle watch --no-compress --jsx React.createElement --format modern,cjs",
"test": "jest"
"test": "jest --verbose"
},
"keywords": [
"next.js",
Expand Down
25 changes: 25 additions & 0 deletions packages/next-drupal/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
setupFiles: ["dotenv/config"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
testMatch: ["**/tests/**/*.test.{ts,tsx}"],
globals: {
"ts-jest": {
isolatedModules: true,
},
},
coverageProvider: "v8",
collectCoverage: true,
collectCoverageFrom: ["./src/**"],
coveragePathIgnorePatterns: ["./src/get-*"],
coverageThreshold: {
global: {
statements: 58.91,
branches: 74.61,
functions: 77.77,
lines: 58.91,
},
},
}
1 change: 1 addition & 0 deletions packages/next-drupal/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "isomorphic-fetch"
2 changes: 1 addition & 1 deletion packages/next-drupal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"prepare": "microbundle --no-compress --jsx React.createElement --format modern,cjs",
"dev": "microbundle watch --no-compress --jsx React.createElement --format modern,cjs",
"test": "jest"
"test": "jest --verbose"
},
"keywords": [
"next.js",
Expand Down

0 comments on commit 399a64a

Please sign in to comment.