@mysetup/test-helpers 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,50 @@
1
1
  # @mysetup/test-helpers
2
2
 
3
- A collection of helpful testing functions based on [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/).
3
+ Testing utilities built on top of React Testing Library, `jest-axe`, and Apollo testing helpers.
4
4
 
5
- ## Usage
5
+ ## Installation
6
6
 
7
- ### `setupRender`
7
+ ```bash
8
+ pnpm add -D @mysetup/test-helpers react react-dom
9
+ ```
8
10
 
9
- `setupRender` accepts a component and default props, and returns a `render` function that will merge additional props to the component.
11
+ ## Supported libraries and runtimes
10
12
 
11
- ```tsx
12
- import { screen, setupRender } from "../../test-helpers";
13
+ | Supported | Notes |
14
+ | --------------------- | ---------------------------- |
15
+ | Jest + jsdom | Supported |
16
+ | React Testing Library | Supported |
17
+ | Next.js test suites | Supported |
18
+ | Vitest | Not targeted by this package |
13
19
 
14
- const render = setupRender(<Component />, { text: "default props" });
20
+ ## Usage
15
21
 
16
- describe("setupRender", () => {
17
- test("default props", () => {
18
- render();
22
+ ```tsx
23
+ import { screen, setupRender } from "@mysetup/test-helpers";
19
24
 
20
- expect(screen.getByText("default prop")).toBeInTheDocument();
21
- });
25
+ function Component({ text }: { text: string }) {
26
+ return <div>{text}</div>;
27
+ }
22
28
 
23
- test("default props", () => {
24
- render({ moreText: "more props" });
29
+ const render = setupRender(Component, { text: "default value" });
25
30
 
26
- expect(screen.getByText("default props")).toBeInTheDocument();
27
- expect(screen.getByText("more props")).toBeInTheDocument();
28
- });
31
+ test("renders merged props", () => {
32
+ render({ text: "overridden" });
33
+ expect(screen.getByText("overridden")).toBeInTheDocument();
29
34
  });
30
35
  ```
36
+
37
+ ## Exports
38
+
39
+ - `setupRender`
40
+ - `setupRenderWithProvider`
41
+ - `setupRenderHook`
42
+ - `setupRenderHookWithProvider`
43
+ - `MockedProvider`
44
+ - Testing Library re-exports
45
+ - `jest-axe` re-exports
46
+
47
+ ## Notes
48
+
49
+ - This package currently uses `@jest/globals` and mocks `next/navigation`, so it is designed for Jest-based test setups.
50
+ - If your app uses Vite, this package is suitable when your tests run on Jest rather than Vitest.
@@ -2,4 +2,3 @@ import React from "react";
2
2
  import type { MockedProviderProps } from "@apollo/client/testing";
3
3
  export * from "@apollo/client/testing";
4
4
  export declare const MockedProvider: ({ children, ...props }: MockedProviderProps) => React.JSX.Element;
5
- //# sourceMappingURL=index.d.ts.map
@@ -30,4 +30,3 @@ export declare const getById: (container: HTMLElement, id: import("@testing-libr
30
30
  export { userEvent };
31
31
  export * from "jest-axe";
32
32
  export * from "@testing-library/react";
33
- //# sourceMappingURL=index.d.ts.map
@@ -107,7 +107,7 @@ var setupRenderWithProvider = function (Component, Provider, defaultAppState, de
107
107
  });
108
108
  }
109
109
  return (0, react_1.render)(react_2.default.createElement(graphql_1.MockedProvider, { mocks: mocks },
110
- react_2.default.createElement(Provider, { appState: appState, version: "test" }, Wrapper ? (react_2.default.createElement(Wrapper, null,
110
+ react_2.default.createElement(Provider, { appState: appState }, Wrapper ? (react_2.default.createElement(Wrapper, null,
111
111
  react_2.default.createElement(Component, __assign({}, props)))) : (react_2.default.createElement(Component, __assign({}, props))))), options);
112
112
  };
113
113
  };
@@ -139,7 +139,7 @@ var setupRenderHookWithProvider = function (hook, Provider, defaultAppState, def
139
139
  return (0, react_1.renderHook)(function () { return hook(props); }, __assign(__assign({}, options), { wrapper: function (_a) {
140
140
  var children = _a.children;
141
141
  return (react_2.default.createElement(graphql_1.MockedProvider, { mocks: mocks },
142
- react_2.default.createElement(Provider, { appState: appState, version: "test" }, Wrapper ? react_2.default.createElement(Wrapper, null, children) : children)));
142
+ react_2.default.createElement(Provider, { appState: appState }, Wrapper ? react_2.default.createElement(Wrapper, null, children) : children)));
143
143
  } }));
144
144
  };
145
145
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./graphql";
2
2
  export * from "./helpers";
3
- //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,60 +1,77 @@
1
1
  {
2
- "name": "@mysetup/test-helpers",
3
- "version": "2.0.1",
4
- "license": "MIT",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist"
8
- ],
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.js"
14
- },
15
- "./package.json": "./package.json"
2
+ "name": "@mysetup/test-helpers",
3
+ "version": "2.0.3",
4
+ "description": "Shared React and Apollo test helpers for application packages.",
5
+ "author": "krishnaraj <krishnaraj.webdev@gmail.com>",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "testing",
9
+ "react-testing-library",
10
+ "apollo",
11
+ "nextjs",
12
+ "typescript"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "sideEffects": false,
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.js"
16
28
  },
17
- "scripts": {
18
- "build": "rm -rf ./dist && tsc -p tsconfig.build.json",
19
- "lint": "eslint .",
20
- "test": "jest",
21
- "test:update": "pnpm test -- -u",
22
- "test:coverage": "jest --coverage",
23
- "typecheck": "tsc --noEmit",
24
- "format": "prettier --write \"**/*.{ts,tsx,md,js,mjs,json}\"",
25
- "checks": "pnpm typecheck && pnpm lint && pnpm test",
26
- "clean": "rm -rf node_modules .swc dist pnpm-lock.yaml && echo \"✅ Successfully removed \""
27
- },
28
- "dependencies": {
29
- "@apollo/client": "^3.12.9",
30
- "@jest/globals": "^29.7.0",
31
- "@testing-library/dom": "^10.4.0",
32
- "@testing-library/jest-dom": "^6.6.3",
33
- "@testing-library/react": "^16.2.0",
34
- "@testing-library/user-event": "^14.6.1",
35
- "next": "^15.1.9",
36
- "react": "^18.3.1",
37
- "react-aria": "^3.37.0",
38
- "react-dom": "^18.3.1"
39
- },
40
- "devDependencies": {
41
- "@mysetup/eslint-config": "latest",
42
- "@mysetup/jest-config": "latest",
43
- "@mysetup/prettier-config": "latest",
44
- "@mysetup/tsconfig": "latest",
45
- "@mysetup/types": "latest",
46
- "@types/jest": "^29.5.14",
47
- "@types/jest-axe": "^3.5.9",
48
- "@types/node": "^22.13.1",
49
- "@types/react": "^18.3.1",
50
- "@types/react-dom": "^18.3.1",
51
- "jest": "^29.7.0",
52
- "jest-axe": "^9.0.0",
53
- "typescript": "5.5.4"
54
- },
55
- "prettier": "@mysetup/prettier-config",
56
- "engines": {
57
- "node": ">=20.15.1"
58
- },
59
- "packageManager": "pnpm@9.9.0"
60
- }
29
+ "./package.json": "./package.json"
30
+ },
31
+ "dependencies": {
32
+ "@apollo/client": "^3.12.9",
33
+ "@jest/globals": "^29.7.0",
34
+ "@testing-library/dom": "^10.4.0",
35
+ "@testing-library/jest-dom": "^6.6.3",
36
+ "@testing-library/react": "^16.2.0",
37
+ "@testing-library/user-event": "^14.6.1",
38
+ "next": "^15.1.9",
39
+ "react-aria": "^3.37.0"
40
+ },
41
+ "peerDependencies": {
42
+ "react": "^18.3.1 || ^19.0.0",
43
+ "react-dom": "^18.3.1 || ^19.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/jest": "^29.5.14",
47
+ "@types/jest-axe": "^3.5.9",
48
+ "@types/node": "^22.13.1",
49
+ "@types/react": "^18.3.1",
50
+ "@types/react-dom": "^18.3.1",
51
+ "jest": "^29.7.0",
52
+ "jest-axe": "^9.0.0",
53
+ "react": "^18.3.1",
54
+ "react-dom": "^18.3.1",
55
+ "typescript": "5.5.4",
56
+ "@mysetup/eslint-config": "^2.0.5",
57
+ "@mysetup/prettier-config": "^2.0.4",
58
+ "@mysetup/tsconfig": "^2.0.4",
59
+ "@mysetup/types": "^2.0.7",
60
+ "@mysetup/jest-config": "^2.0.4"
61
+ },
62
+ "prettier": "@mysetup/prettier-config",
63
+ "engines": {
64
+ "node": ">=20.15.1"
65
+ },
66
+ "scripts": {
67
+ "build": "node ../scripts/package-fs.cjs remove dist && tsc -p tsconfig.build.json",
68
+ "lint": "node ../scripts/run-eslint.cjs .",
69
+ "test": "jest",
70
+ "test:update": "pnpm test -- -u",
71
+ "test:coverage": "jest --coverage",
72
+ "typecheck": "tsc --noEmit",
73
+ "format": "prettier --write \"**/*.{ts,tsx,md,js,mjs,json}\"",
74
+ "checks": "pnpm typecheck && pnpm lint && pnpm test && pnpm build",
75
+ "clean": "node ../scripts/package-fs.cjs remove node_modules .swc dist pnpm-lock.yaml && echo \"Cleaned\""
76
+ }
77
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../graphql/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,cAAc,wBAAwB,CAAC;AAEvC,eAAO,MAAM,cAAc,2BAA4B,mBAAmB,sBAiBzE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../helpers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,MAAM,EAEN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAc,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,KAAK,WAAW,GAAG,mBAAmB,GAAG,cAAc,GAAG,cAAc,CAAC;AAEzE,UAAU,cAAc;IAC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