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 32a5a0a commit ca05185
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/next-drupal-query.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: next-drupal-query
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, edited]

Expand All @@ -12,4 +14,4 @@ jobs:
- name: Install modules
run: yarn
- name: Run tests
run: yarn test packages/next-drupal-query
run: yarn workspace next-drupal-query test
2 changes: 1 addition & 1 deletion .github/workflows/next-drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install modules
run: yarn
- name: Run tests
run: yarn test packages/next-drupal
run: yarn workspace next-drupal test
env:
DRUPAL_BASE_URL: ${{ secrets.DRUPAL_BASE_URL }}
DRUPAL_USERNAME: ${{ secrets.DRUPAL_USERNAME }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: next
on:
push:
branches:
- main
pull_request:
branches:
- main
Expand Down
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 @@ -31,7 +31,7 @@
"scripts": {
"prepare": "tsup",
"dev": "tsup --watch",
"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 @@ -44,7 +44,7 @@
"scripts": {
"prepare": "tsup",
"dev": "tsup --watch",
"test": "jest"
"test": "jest --verbose"
},
"keywords": [
"next.js",
Expand Down

0 comments on commit ca05185

Please sign in to comment.