Skip to content

Commit

Permalink
update deps + fix id query function
Browse files Browse the repository at this point in the history
  • Loading branch information
Raice Hannay committed Sep 15, 2022
1 parent 3440a70 commit 09121ab
Show file tree
Hide file tree
Showing 7 changed files with 2,152 additions and 2,082 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
21 changes: 12 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ module.exports = {
statements: 100,
},
},
globals: {
"ts-jest": {
tsconfig: {
target: "es6",
},
},
},
moduleDirectories: ["node_modules"],
preset: "ts-jest",
roots: ["<rootDir>/src"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
snapshotSerializers: ["enzyme-to-json/serializer"],
testEnvironment: "jsdom",
testEnvironmentOptions: { url: "http://localhost" },
testMatch: ["**/*.test.{ts,tsx}"],
testURL: "http://localhost",
transform: {
"^.+.tsx?$": [
"ts-jest",
{
tsconfig: {
sourceMap: true,
target: "es6",
},
},
],
},
transformIgnorePatterns: [
"/node_modules/(?!intl-messageformat|intl-messageformat-parser).+\\.js$",
],
Expand Down
60 changes: 34 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Raice Hannay <voodoocreation@gmail.com>",
"description": "A set of classes to make setting up React components for unit tests easy.",
"license": "ISC",
"version": "3.0.4",
"version": "3.0.5",
"keywords": [
"component",
"enzyme",
Expand Down Expand Up @@ -31,10 +31,11 @@
"lint": "eslint \"./src/**/*.ts?(x)\"",
"lint:fix": "eslint \"./src/**/*.ts?(x)\" --fix",
"test": "cross-env NODE_ENV=test jest --no-cache --runInBand --config ./jest.config.js",
"test:all": "npm-run-all format typecheck lint:fix test:coverage",
"test:all": "npm-run-all clean format typecheck lint:fix test:coverage",
"test:coverage": "cross-env NODE_ENV=test jest --no-cache --runInBand --coverage --config ./jest.config.js",
"typecheck": "tsc",
"prepack": "rimraf ./enzyme && rimraf ./react-testing-library && tsc"
"typecheck": "tsc --noEmit",
"clean": "rimraf ./enzyme && rimraf ./react-testing-library",
"prepack": "yarn clean && tsc"
},
"repository": {
"type": "git",
Expand All @@ -47,8 +48,9 @@
"types": "dist/index.d.ts",
"peerDependencies": {
"@testing-library/react": ">= 12.0.0",
"@types/react": "^17.0.14",
"enzyme": ">= 3.11.0",
"react": ">= 17.0.2",
"react": "~17.0.2",
"react-intl": ">= 5.17.5",
"react-redux": ">= 7.2.4",
"redux": ">= 4.1.0"
Expand All @@ -72,39 +74,45 @@
},
"devDependencies": {
"@testing-library/react": "^12.0.0",
"@types/enzyme": "^3.10.9",
"@types/jest": "^26.0.24",
"@types/enzyme": "^3.10.12",
"@types/jest": "^29.0.2",
"@types/react": "^17.0.14",
"@types/react-redux": "^7.1.17",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2",
"@types/react-redux": "^7.1.24",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"eslint": "^7.30.0",
"eslint-config-voodoocreation": "^2.0.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint": "^8.23.1",
"eslint-config-voodoocreation": "^3.0.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.0.4",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.0.6",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"prettier": "^2.7.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-intl": "^5.20.4",
"react-redux": "^7.2.4",
"redux": "^4.1.0",
"react-intl": "^6.1.1",
"react-redux": "^8.0.2",
"redux": "^4.2.0",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.3",
"typescript": "^4.3.5",
"ts-jest": "^29.0.1",
"typescript": "^4.8.3",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.2"
},
"dependencies": {
"ts-deepmerge": "^1.0.8"
"ts-deepmerge": "^4.0.0"
},
"resolutions": {
"@types/react": "^17",
"react": "^17",
"react-dom": "^17"
}
}
9 changes: 4 additions & 5 deletions src/react-testing-library/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getMissingError = (attr: string) => (_: any, value: string) =>
`Unable to find an element where ${attr} matches ${value}`;

const queryAllById: TFn = (container, id) =>
Array.from(container.querySelectorAll(`.${id}`));
Array.from(container.querySelectorAll(`#${id}`));

const queryAllByClassName: TFn = (container, id) =>
Array.from(container.querySelectorAll(`.${id}`));
Expand All @@ -30,7 +30,7 @@ const [
getAllByClassName,
getByClassName,
findAllByClassName,
findByClassName
findByClassName,
] = buildQueries(
queryAllByClassName,
getMultipleError("className"),
Expand All @@ -42,14 +42,13 @@ const [
getAllBySelector,
getBySelector,
findAllBySelector,
findBySelector
findBySelector,
] = buildQueries(
queryAllBySelector,
getMultipleError("tag name"),
getMissingError("tag name")
);


export {
queryById,
queryAllById,
Expand All @@ -68,5 +67,5 @@ export {
getAllBySelector,
getBySelector,
findAllBySelector,
findBySelector
findBySelector,
};
2 changes: 1 addition & 1 deletion test/IntlDummy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import { FormattedMessage } from "react-intl";

interface IProps {
children: React.ReactNode | React.ReactNode[];
children: React.ReactNode;
onClick?: (value: string) => void;
value: string;
}
Expand Down
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"baseUrl": ".",
"declaration": true,
"outDir": "./",
"sourceMap": true,
"sourceMap": false,
"module": "commonjs",
"target": "es5",
"lib": ["dom", "esnext"],
Expand All @@ -18,5 +18,11 @@
"noUnusedParameters": true
},
"include": ["src/enzyme/index.ts", "src/react-testing-library/index.ts"],
"exclude": ["**/coverage/*", "**/dist/*", "./react-testing-library", "./enzyme", "**/node_modules/*"]
"exclude": [
"**/coverage/*",
"**/dist/*",
"./react-testing-library",
"./enzyme",
"**/node_modules/*"
]
}
Loading

0 comments on commit 09121ab

Please sign in to comment.