Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooling to test code coverage #610

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 additions & 0 deletions packages/next-drupal-query/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/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/**"],
coverageReporters: ["lcov", "text", "text-summary"],
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
27 changes: 27 additions & 0 deletions packages/next-drupal/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @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-*"],
coverageReporters: ["lcov", "text", "text-summary"],
coverageThreshold: {
global: {
// @TODO Make these thresholds strict once #608 is completed.
statements: 55, // 57.38,
branches: 80, // 83.85,
functions: 75, // 76.36,
lines: 55, // 57.38,
},
},
}
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