-
Notifications
You must be signed in to change notification settings - Fork 177
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
test(next-drupal): reorganize Jest tests #675
Changes from all commits
2c4028c
109213e
50642c5
f99ffeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
"format:check": "prettier --check .", | ||
"phpcs": "./drupal/vendor/bin/phpcs -p -s --colors --standard=modules/next/phpcs.xml modules/next", | ||
"test:next": "SIMPLETEST_DB=sqlite://localhost/:memory: ./drupal/vendor/bin/phpunit -c ./drupal/web/core modules/next", | ||
"sync:modules": "./scripts/sync-repo.sh 1.0.x [email protected]:project/ \"modules/*\"", | ||
"sync:modules": "./scripts/sync-repo.sh 2.x [email protected]:project/ \"modules/*\"", | ||
"sync:examples": "./scripts/sync-repo.sh main [email protected]:chapter-three/next- \"examples/example-*\"", | ||
"sync:starters": "./scripts/sync-repo.sh canary [email protected]:chapter-three/next-drupal- \"starters/*\"", | ||
"sync:starters:release": "./scripts/sync-repo.sh canary,main [email protected]:chapter-three/next-drupal- \"starters/*\"", | ||
|
@@ -32,46 +32,46 @@ | |
"test:e2e:ci": "turbo run test:e2e:ci --parallel" | ||
}, | ||
"resolutions": { | ||
"@types/react": "17.0.68", | ||
"@types/react-dom": "17.0.21" | ||
"@types/react": "17.0.75", | ||
"@types/react-dom": "17.0.25" | ||
}, | ||
"devDependencies": { | ||
"@actions/core": "^1.10.1", | ||
"@babel/core": "^7.23.2", | ||
"@babel/eslint-parser": "^7.22.15", | ||
"@babel/plugin-transform-runtime": "^7.23.2", | ||
"@babel/preset-env": "^7.23.2", | ||
"@babel/preset-react": "^7.22.15", | ||
"@commitlint/cli": "^18.6.0", | ||
"@commitlint/config-conventional": "^17.8.0", | ||
"@babel/core": "^7.23.9", | ||
"@babel/eslint-parser": "^7.23.10", | ||
"@babel/plugin-transform-runtime": "^7.23.9", | ||
"@babel/preset-env": "^7.23.9", | ||
"@babel/preset-react": "^7.23.3", | ||
"@commitlint/cli": "^18.6.1", | ||
"@commitlint/config-conventional": "^18.6.2", | ||
"@next/eslint-plugin-next": "^12.3.4", | ||
"@testing-library/cypress": "^8.0.7", | ||
"@types/jest": "^27.5.2", | ||
"@types/node": "^17.0.45", | ||
"@types/react": "^17.0.68", | ||
"@types/react-dom": "^17.0.21", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.11.19", | ||
"@types/react": "^17.0.75", | ||
"@types/react-dom": "^17.0.25", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^5.62.0", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"cypress": "^9.7.0", | ||
"eslint": "^8.51.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-cypress": "^2.15.1", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-react": "^7.33.2", | ||
"faker": "^6.6.6", | ||
"husky": "^9.0.11", | ||
"isomorphic-fetch": "^3.0.0", | ||
"jest": "^27.5.1", | ||
"lerna": "^8.0.1", | ||
"lint-staged": "^15.0.2", | ||
"prettier": "^3.0.3", | ||
"jest": "^29.7.0", | ||
"lerna": "^8.1.2", | ||
"lint-staged": "^15.2.2", | ||
"prettier": "^3.2.5", | ||
"start-server-and-test": "^1.15.5", | ||
"ts-jest": "^27.1.5", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^7.3.0", | ||
"turbo": "^1.10.15", | ||
"typescript": "^5.2.2", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.0.2", | ||
"turbo": "^1.12.4", | ||
"typescript": "^5.3.3", | ||
"uuid": "^9.0.1", | ||
"yaml": "^2.3.3" | ||
"yaml": "^2.3.4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
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, | ||
}, | ||
transform: { | ||
"^.+\\.tsx?$": [ | ||
"ts-jest", | ||
{ | ||
isolatedModules: true, | ||
}, | ||
], | ||
}, | ||
testLocationInResults: true, | ||
coverageProvider: "v8", | ||
collectCoverage: true, | ||
collectCoverageFrom: ["./src/**"], | ||
coverageReporters: ["lcov", "text", "text-summary"], | ||
coverageThreshold: { | ||
global: { | ||
statements: 85.11, | ||
branches: 58, | ||
statements: 84.22, | ||
branches: 64.1, | ||
functions: 70, | ||
lines: 85.11, | ||
lines: 84.22, | ||
}, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`formatData it formats data 1`] = ` | ||
Object { | ||
{ | ||
"name": "First Last", | ||
} | ||
`; | ||
|
||
exports[`getData it accepts data options 1`] = ` | ||
Object { | ||
{ | ||
"author": "shadcn", | ||
"id": "ID", | ||
"title": "Title of Article", | ||
|
@@ -16,14 +16,14 @@ Object { | |
`; | ||
|
||
exports[`getData it accepts placeholder options 1`] = ` | ||
Object { | ||
{ | ||
"email": "[email protected]", | ||
"name": "shadcn", | ||
} | ||
`; | ||
|
||
exports[`getData it returns data for a query 1`] = ` | ||
Object { | ||
{ | ||
"author": "shadcn", | ||
"id": "id", | ||
"title": "Title of Article", | ||
|
@@ -32,52 +32,52 @@ Object { | |
`; | ||
|
||
exports[`getData it returns data when both data and placeholder is defined 1`] = ` | ||
Object { | ||
{ | ||
"email": "[email protected]", | ||
} | ||
`; | ||
|
||
exports[`getData it returns formatted data if a formatter is defined 1`] = ` | ||
Object { | ||
{ | ||
"email": "[email protected]", | ||
"name": "First Last", | ||
} | ||
`; | ||
|
||
exports[`getData it returns placeholder data if a query does not define data 1`] = ` | ||
Object { | ||
{ | ||
"name": "shadcn", | ||
} | ||
`; | ||
|
||
exports[`getParams it accepts params options 1`] = ` | ||
Object { | ||
"fields": Object { | ||
{ | ||
"fields": { | ||
"resource": "foo,bar", | ||
}, | ||
"filter": Object {}, | ||
"include": Array [], | ||
"sort": Array [], | ||
"filter": {}, | ||
"include": [], | ||
"sort": [], | ||
} | ||
`; | ||
|
||
exports[`getParams it allows params to be nested 1`] = ` | ||
Object { | ||
"fields": Object {}, | ||
"filter": Object {}, | ||
{ | ||
"fields": {}, | ||
"filter": {}, | ||
"include": "field_image,uid", | ||
"page": Object { | ||
"page": { | ||
"limit": 10, | ||
}, | ||
"sort": Array [], | ||
"sort": [], | ||
} | ||
`; | ||
|
||
exports[`getParams it returns params for a query 1`] = ` | ||
Object { | ||
"fields": Object {}, | ||
"filter": Object {}, | ||
{ | ||
"fields": {}, | ||
"filter": {}, | ||
"include": "field_image,uid", | ||
"sort": Array [], | ||
"sort": [], | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
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, | ||
}, | ||
transform: { | ||
"^.+\\.tsx?$": [ | ||
"ts-jest", | ||
{ | ||
isolatedModules: true, | ||
}, | ||
], | ||
}, | ||
testLocationInResults: true, | ||
coverageProvider: "v8", | ||
collectCoverage: true, | ||
collectCoverageFrom: ["./src/**"], | ||
coveragePathIgnorePatterns: ["./src/get-*"], | ||
coveragePathIgnorePatterns: [ | ||
"./src/deprecated/*", | ||
"./src/deprecated.ts", | ||
"./src/navigation.ts", | ||
"./src/types/*", | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason to track code coverage of the deprecated API. And TypeScript removes |
||
coverageReporters: ["lcov", "text", "text-summary"], | ||
coverageThreshold: { | ||
global: { | ||
// @TODO Make these thresholds strict once #608 is completed. | ||
statements: 50, // 55.1, | ||
branches: 80, // 84.16, | ||
functions: 70, // 72.41, | ||
lines: 50, // 55.1, | ||
statements: 100, | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yay! 100% code coverage. |
||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
testLocationInResults
flag shows the directory and filename of all thetest.ts
files which makes it way easier to organize the tests and quickly see where a failing test is.