@cedarjs/testing 0.1.1-next.0 → 0.1.2-next.95

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.
Files changed (95) hide show
  1. package/config/jest/api/jest.setup.js +1 -1
  2. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/code.js +28 -0
  3. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/output.js +35 -0
  4. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/code.js +7 -0
  5. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/output.js +6 -0
  6. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/code.js +3 -0
  7. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/output.js +3 -0
  8. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/code.js +28 -0
  9. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/output.js +34 -0
  10. package/config/jest/babelPlugins/__tests__/__fixtures__/viteDistDir/client-build-manifest.json +59 -0
  11. package/config/jest/babelPlugins/__tests__/babel-plugin-redwood-cell.test.ts +11 -0
  12. package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +142 -0
  13. package/config/jest/package.json +3 -0
  14. package/config/jest/web/jest-preset.js +2 -2
  15. package/config/jest/web/jest.setup.js +2 -2
  16. package/config/jest/web/webBabelConfig.js +16 -1
  17. package/dist/api/apiFunction.js +4 -30
  18. package/dist/api/directUrlHelpers.js +4 -39
  19. package/dist/api/directive.js +13 -38
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/api/index.js +3 -26
  23. package/dist/api/scenario.js +2 -26
  24. package/dist/cache/index.js +2 -26
  25. package/dist/cjs/api/apiFunction.d.ts +37 -0
  26. package/dist/cjs/api/apiFunction.d.ts.map +1 -0
  27. package/dist/cjs/api/apiFunction.js +89 -0
  28. package/dist/cjs/api/directUrlHelpers.d.ts +3 -0
  29. package/dist/cjs/api/directUrlHelpers.d.ts.map +1 -0
  30. package/dist/cjs/api/directUrlHelpers.js +60 -0
  31. package/dist/cjs/api/directive.d.ts +51 -0
  32. package/dist/cjs/api/directive.d.ts.map +1 -0
  33. package/dist/cjs/api/directive.js +77 -0
  34. package/dist/cjs/api/index.d.ts +4 -0
  35. package/dist/cjs/api/index.d.ts.map +1 -0
  36. package/dist/cjs/api/index.js +26 -0
  37. package/dist/cjs/api/scenario.d.ts +108 -0
  38. package/dist/cjs/api/scenario.d.ts.map +1 -0
  39. package/dist/cjs/api/scenario.js +30 -0
  40. package/dist/cjs/cache/index.d.ts +50 -0
  41. package/dist/cjs/cache/index.d.ts.map +1 -0
  42. package/dist/cjs/cache/index.js +104 -0
  43. package/dist/cjs/package.json +1 -0
  44. package/dist/cjs/web/MockParamsProvider.d.ts +7 -0
  45. package/dist/cjs/web/MockParamsProvider.d.ts.map +1 -0
  46. package/dist/cjs/web/MockParamsProvider.js +44 -0
  47. package/dist/cjs/web/MockProviders.d.ts +9 -0
  48. package/dist/cjs/web/MockProviders.d.ts.map +1 -0
  49. package/dist/cjs/web/MockProviders.js +53 -0
  50. package/dist/cjs/web/MockRouter.d.ts +14 -0
  51. package/dist/cjs/web/MockRouter.d.ts.map +1 -0
  52. package/dist/cjs/web/MockRouter.js +48 -0
  53. package/dist/cjs/web/customRender.d.ts +6 -0
  54. package/dist/cjs/web/customRender.d.ts.map +1 -0
  55. package/dist/cjs/web/customRender.js +54 -0
  56. package/dist/cjs/web/fileMock.d.ts +9 -0
  57. package/dist/cjs/web/fileMock.d.ts.map +1 -0
  58. package/dist/cjs/web/fileMock.js +24 -0
  59. package/dist/cjs/web/findCellMocks.d.ts +2 -0
  60. package/dist/cjs/web/findCellMocks.d.ts.map +1 -0
  61. package/dist/cjs/web/findCellMocks.js +45 -0
  62. package/dist/cjs/web/global.d.ts +6 -0
  63. package/dist/cjs/web/global.d.ts.map +1 -0
  64. package/dist/cjs/web/global.js +1 -0
  65. package/dist/cjs/web/index.d.ts +6 -0
  66. package/dist/cjs/web/index.d.ts.map +1 -0
  67. package/dist/cjs/web/index.js +41 -0
  68. package/dist/cjs/web/mockAuth.d.ts +29 -0
  69. package/dist/cjs/web/mockAuth.d.ts.map +1 -0
  70. package/dist/cjs/web/mockAuth.js +89 -0
  71. package/dist/cjs/web/mockRequests.d.ts +30 -0
  72. package/dist/cjs/web/mockRequests.d.ts.map +1 -0
  73. package/dist/cjs/web/mockRequests.js +139 -0
  74. package/dist/web/MockParamsProvider.js +7 -41
  75. package/dist/web/MockProviders.d.ts.map +1 -1
  76. package/dist/web/MockProviders.js +10 -44
  77. package/dist/web/MockRouter.js +10 -37
  78. package/dist/web/customRender.js +9 -44
  79. package/dist/web/fileMock.js +3 -23
  80. package/dist/web/findCellMocks.js +4 -38
  81. package/dist/web/global.d.ts +1 -1
  82. package/dist/web/global.d.ts.map +1 -1
  83. package/dist/web/global.js +0 -1
  84. package/dist/web/index.d.ts +4 -5
  85. package/dist/web/index.d.ts.map +1 -1
  86. package/dist/web/index.js +13 -41
  87. package/dist/web/mockAuth.js +12 -49
  88. package/dist/web/mockRequests.js +6 -37
  89. package/package.json +79 -15
  90. package/api/index.js +0 -2
  91. package/api/package.json +0 -4
  92. package/cache/index.js +0 -2
  93. package/cache/package.json +0 -4
  94. package/web/index.js +0 -2
  95. package/web/package.json +0 -4
package/dist/web/index.js CHANGED
@@ -1,42 +1,14 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var web_exports = {};
21
- __export(web_exports, {
22
- MockProviders: () => import_MockProviders.MockProviders,
23
- render: () => import_customRender.customRender,
24
- renderHook: () => import_customRender.customRenderHook,
25
- useAuth: () => import_mockAuth.useAuth
26
- });
27
- module.exports = __toCommonJS(web_exports);
28
- var import_global = require("./global");
29
- __reExport(web_exports, require("@testing-library/react"), module.exports);
30
- var import_customRender = require("./customRender");
31
- var import_MockProviders = require("./MockProviders");
32
- var import_mockAuth = require("./mockAuth");
33
- __reExport(web_exports, require("./mockRequests"), module.exports);
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
1
+ export * from "@testing-library/react";
2
+ import {
3
+ customRender,
4
+ customRenderHook
5
+ } from "./customRender.js";
6
+ import { MockProviders } from "./MockProviders.js";
7
+ import { useAuth } from "./mockAuth.js";
8
+ export * from "./mockRequests.js";
9
+ export {
36
10
  MockProviders,
37
- render,
38
- renderHook,
39
- useAuth,
40
- ...require("@testing-library/react"),
41
- ...require("./mockRequests")
42
- });
11
+ customRender as render,
12
+ customRenderHook as renderHook,
13
+ useAuth
14
+ };
@@ -1,43 +1,8 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var mockAuth_exports = {};
31
- __export(mockAuth_exports, {
32
- createAuthentication: () => createAuthentication,
33
- useAuth: () => useAuth
34
- });
35
- module.exports = __toCommonJS(mockAuth_exports);
36
- var import_react = __toESM(require("react"));
37
- __reExport(mockAuth_exports, require("@cedarjs/auth"), module.exports);
38
- var import_mockRequests = require("./mockRequests");
1
+ import React from "react";
2
+ export * from "@cedarjs/auth";
3
+ import { mockedUserMeta } from "./mockRequests.js";
39
4
  const AuthProvider = ({ children }) => {
40
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children);
5
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
41
6
  };
42
7
  function makeArray(input) {
43
8
  return !input ? [] : Array.isArray(input) ? input : [input];
@@ -45,20 +10,20 @@ function makeArray(input) {
45
10
  function useAuth() {
46
11
  return {
47
12
  loading: false,
48
- isAuthenticated: !!import_mockRequests.mockedUserMeta.currentUser,
13
+ isAuthenticated: !!mockedUserMeta.currentUser,
49
14
  logIn: async () => {
50
15
  },
51
16
  logOut: async () => {
52
17
  },
53
18
  signUp: async () => {
54
19
  },
55
- currentUser: import_mockRequests.mockedUserMeta.currentUser,
56
- userMetadata: import_mockRequests.mockedUserMeta.currentUser,
20
+ currentUser: mockedUserMeta.currentUser,
21
+ userMetadata: mockedUserMeta.currentUser,
57
22
  getToken: async () => null,
58
- getCurrentUser: async () => import_mockRequests.mockedUserMeta.currentUser,
23
+ getCurrentUser: async () => mockedUserMeta.currentUser,
59
24
  hasRole: (roles) => {
60
25
  const currentUserRoles = makeArray(
61
- import_mockRequests.mockedUserMeta.currentUser?.roles
26
+ mockedUserMeta.currentUser?.roles
62
27
  );
63
28
  if (currentUserRoles) {
64
29
  return makeArray(roles).some((role) => currentUserRoles.includes(role));
@@ -81,9 +46,7 @@ function useAuth() {
81
46
  const createAuthentication = () => {
82
47
  return { AuthProvider, useAuth };
83
48
  };
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
49
+ export {
86
50
  createAuthentication,
87
- useAuth,
88
- ...require("@cedarjs/auth")
89
- });
51
+ useAuth
52
+ };
@@ -1,34 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var mockRequests_exports = {};
20
- __export(mockRequests_exports, {
21
- closeServer: () => closeServer,
22
- mockCurrentUser: () => mockCurrentUser,
23
- mockGraphQLMutation: () => mockGraphQLMutation,
24
- mockGraphQLQuery: () => mockGraphQLQuery,
25
- mockedUserMeta: () => mockedUserMeta,
26
- registerHandler: () => registerHandler,
27
- setupRequestHandlers: () => setupRequestHandlers,
28
- startMSW: () => startMSW
29
- });
30
- module.exports = __toCommonJS(mockRequests_exports);
31
- var import_msw = require("msw");
1
+ import { setupWorker, graphql } from "msw";
32
2
  let REQUEST_HANDLER_QUEUE = [];
33
3
  let SERVER_INSTANCE;
34
4
  const startMSW = async (target, options) => {
@@ -36,10 +6,10 @@ const startMSW = async (target, options) => {
36
6
  return SERVER_INSTANCE;
37
7
  }
38
8
  if (target === "browsers") {
39
- SERVER_INSTANCE = (0, import_msw.setupWorker)();
9
+ SERVER_INSTANCE = setupWorker();
40
10
  await SERVER_INSTANCE.start(options);
41
11
  } else {
42
- const { setupServer } = require("msw/node");
12
+ const { setupServer } = await import("msw/node");
43
13
  SERVER_INSTANCE = setupServer();
44
14
  await SERVER_INSTANCE.listen(options);
45
15
  }
@@ -94,7 +64,7 @@ const mockGraphQL = (type, operation, data, responseEnhancer) => {
94
64
  ...responseTransforms
95
65
  );
96
66
  };
97
- registerHandler(import_msw.graphql[type](operation, resolver));
67
+ registerHandler(graphql[type](operation, resolver));
98
68
  return data;
99
69
  };
100
70
  const mockGraphQLQuery = (operation, data, responseEnhancer) => {
@@ -116,8 +86,7 @@ const mockCurrentUser = (user) => {
116
86
  };
117
87
  });
118
88
  };
119
- // Annotate the CommonJS export names for ESM import in node:
120
- 0 && (module.exports = {
89
+ export {
121
90
  closeServer,
122
91
  mockCurrentUser,
123
92
  mockGraphQLMutation,
@@ -126,4 +95,4 @@ const mockCurrentUser = (user) => {
126
95
  registerHandler,
127
96
  setupRequestHandlers,
128
97
  startMSW
129
- });
98
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/testing",
3
- "version": "0.1.1-next.0+cb894b940",
3
+ "version": "0.1.2-next.95+a711c9cda",
4
4
  "description": "Tools, wrappers and configuration for testing a CedarJS project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,70 @@
8
8
  "directory": "packages/testing"
9
9
  },
10
10
  "license": "MIT",
11
- "type": "commonjs",
11
+ "type": "module",
12
+ "exports": {
13
+ "./config/jest/web": {
14
+ "default": "./config/jest/web/index.js"
15
+ },
16
+ "./config/jest/api": {
17
+ "default": "./config/jest/api/index.js"
18
+ },
19
+ "./config/jest/api/jest-preset": {
20
+ "default": "./config/jest/api/jest-preset.js"
21
+ },
22
+ "./config/jest/web/jest-preset": {
23
+ "default": "./config/jest/web/jest-preset.js"
24
+ },
25
+ "./dist/cjs/api/scenario": {
26
+ "default": "./dist/cjs/api/scenario.js"
27
+ },
28
+ "./dist/cjs/web/findCellMocks": {
29
+ "default": "./dist/cjs/web/findCellMocks.js"
30
+ },
31
+ "./dist/cjs/web/mockRequests": {
32
+ "default": "./dist/cjs/web/mockRequests.js"
33
+ },
34
+ "./auth": {
35
+ "import": {
36
+ "types": "./dist/web/mockAuth.d.ts",
37
+ "default": "./dist/web/mockAuth.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/cjs/web/index.d.ts",
41
+ "default": "./dist/cjs/web/mockAuth.js"
42
+ }
43
+ },
44
+ "./api": {
45
+ "import": {
46
+ "types": "./dist/api/index.d.ts",
47
+ "default": "./dist/api/index.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/cjs/api/index.d.ts",
51
+ "default": "./dist/cjs/api/index.js"
52
+ }
53
+ },
54
+ "./cache": {
55
+ "import": {
56
+ "types": "./dist/cache/index.d.ts",
57
+ "default": "./dist/cache/index.js"
58
+ },
59
+ "require": {
60
+ "types": "./dist/cjs/cache/index.d.ts",
61
+ "default": "./dist/cjs/cache/index.js"
62
+ }
63
+ },
64
+ "./web": {
65
+ "import": {
66
+ "types": "./dist/web/index.d.ts",
67
+ "default": "./dist/web/index.js"
68
+ },
69
+ "require": {
70
+ "types": "./dist/cjs/web/index.d.ts",
71
+ "default": "./dist/cjs/web/index.js"
72
+ }
73
+ }
74
+ },
12
75
  "files": [
13
76
  "config",
14
77
  "web",
@@ -20,6 +83,7 @@
20
83
  "build": "tsx ./build.mts && yarn build:types",
21
84
  "build:pack": "yarn pack -o cedarjs-testing.tgz",
22
85
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
86
+ "build:types-cjs": "tsc --build --verbose tsconfig.cjs.json",
23
87
  "build:watch": "nodemon --watch src --ext 'js,jsx,ts,tsx' --ignore dist --exec 'yarn build'",
24
88
  "check:attw": "yarn rw-fwtools-attw",
25
89
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -28,13 +92,13 @@
28
92
  "test:watch": "vitest watch"
29
93
  },
30
94
  "dependencies": {
31
- "@cedarjs/auth": "0.1.1-next.0+cb894b940",
32
- "@cedarjs/babel-config": "0.1.1-next.0+cb894b940",
33
- "@cedarjs/context": "0.1.1-next.0+cb894b940",
34
- "@cedarjs/graphql-server": "0.1.1-next.0+cb894b940",
35
- "@cedarjs/project-config": "0.1.1-next.0+cb894b940",
36
- "@cedarjs/router": "0.1.1-next.0+cb894b940",
37
- "@cedarjs/web": "0.1.1-next.0+cb894b940",
95
+ "@cedarjs/auth": "0.1.2-next.95+a711c9cda",
96
+ "@cedarjs/babel-config": "0.1.2-next.95+a711c9cda",
97
+ "@cedarjs/context": "0.1.2-next.95+a711c9cda",
98
+ "@cedarjs/graphql-server": "0.1.2-next.95+a711c9cda",
99
+ "@cedarjs/project-config": "0.1.2-next.95+a711c9cda",
100
+ "@cedarjs/router": "0.1.2-next.95+a711c9cda",
101
+ "@cedarjs/web": "0.1.2-next.95+a711c9cda",
38
102
  "@testing-library/jest-dom": "6.5.0",
39
103
  "@testing-library/react": "14.3.1",
40
104
  "@testing-library/user-event": "14.5.2",
@@ -43,7 +107,7 @@
43
107
  "@types/jest": "29.5.14",
44
108
  "@types/node": "20.17.10",
45
109
  "babel-jest": "^29.7.0",
46
- "fast-glob": "3.3.2",
110
+ "fast-glob": "3.3.3",
47
111
  "jest": "29.7.0",
48
112
  "jest-environment-jsdom": "29.7.0",
49
113
  "jest-watch-typeahead": "2.2.2",
@@ -52,16 +116,16 @@
52
116
  "whatwg-fetch": "3.6.20"
53
117
  },
54
118
  "devDependencies": {
55
- "@cedarjs/framework-tools": "0.1.1-next.1",
119
+ "@cedarjs/framework-tools": "0.1.2-next.95",
56
120
  "concurrently": "8.2.2",
57
121
  "jsdom": "24.1.3",
58
- "publint": "0.3.11",
59
- "tsx": "4.19.3",
122
+ "publint": "0.3.12",
123
+ "tsx": "4.19.4",
60
124
  "typescript": "5.6.2",
61
- "vitest": "2.1.9"
125
+ "vitest": "3.2.4"
62
126
  },
63
127
  "publishConfig": {
64
128
  "access": "public"
65
129
  },
66
- "gitHead": "cb894b940413e856e96da4c8fa1712c76b38a7db"
130
+ "gitHead": "a711c9cda09da9444fb0f6ff5d9dae804d6ba72b"
67
131
  }
package/api/index.js DELETED
@@ -1,2 +0,0 @@
1
- /* eslint-env es6, commonjs */
2
- module.exports = require('../dist/api')
package/api/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "main": "./index.js",
3
- "types": "../dist/api/index.d.ts"
4
- }
package/cache/index.js DELETED
@@ -1,2 +0,0 @@
1
- /* eslint-env es6, commonjs */
2
- module.exports = require('../dist/cache')
@@ -1,4 +0,0 @@
1
- {
2
- "main": "./index.js",
3
- "types": "../dist/cache/index.d.ts"
4
- }
package/web/index.js DELETED
@@ -1,2 +0,0 @@
1
- /* eslint-env es6, commonjs */
2
- module.exports = require('../dist/web')
package/web/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "main": "./index.js",
3
- "types": "../dist/web/index.d.ts"
4
- }