@cedarjs/testing 0.7.2-next.2 → 0.7.2-next.49

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 (73) hide show
  1. package/config/jest/api/package.json +8 -0
  2. package/config/jest/web/package.json +8 -0
  3. package/dist/api/mockContext.d.ts +5 -0
  4. package/dist/api/mockContext.d.ts.map +1 -0
  5. package/dist/api/mockContext.js +33 -0
  6. package/dist/api/vitest/CedarApiVitestEnv.d.ts +5 -0
  7. package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -0
  8. package/dist/api/vitest/CedarApiVitestEnv.js +41 -0
  9. package/dist/api/vitest/index.d.ts +4 -0
  10. package/dist/api/vitest/index.d.ts.map +1 -0
  11. package/dist/api/vitest/index.js +8 -0
  12. package/dist/api/vitest/vite-plugin-auto-import.d.ts +2 -0
  13. package/dist/api/vitest/vite-plugin-auto-import.d.ts.map +1 -0
  14. package/dist/api/vitest/vite-plugin-auto-import.js +37 -0
  15. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts +3 -0
  16. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +1 -0
  17. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +34 -0
  18. package/dist/api/vitest/vite-plugin-track-db-imports.d.ts +3 -0
  19. package/dist/api/vitest/vite-plugin-track-db-imports.d.ts.map +1 -0
  20. package/dist/api/vitest/vite-plugin-track-db-imports.js +23 -0
  21. package/dist/api/vitest/vitest-api.setup.d.ts +9 -0
  22. package/dist/api/vitest/vitest-api.setup.d.ts.map +1 -0
  23. package/dist/api/vitest/vitest-api.setup.js +247 -0
  24. package/dist/cjs/api/mockContext.d.ts +5 -0
  25. package/dist/cjs/api/mockContext.d.ts.map +1 -0
  26. package/dist/cjs/api/mockContext.js +58 -0
  27. package/dist/cjs/api/vitest/CedarApiVitestEnv.js +71 -0
  28. package/dist/cjs/api/vitest/index.js +34 -0
  29. package/dist/cjs/api/vitest/vite-plugin-auto-import.js +71 -0
  30. package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +69 -0
  31. package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +47 -0
  32. package/dist/cjs/api/vitest/vitest-api.setup.js +270 -0
  33. package/dist/cjs/web/MockProviders.d.ts +0 -4
  34. package/dist/cjs/web/MockProviders.d.ts.map +1 -1
  35. package/dist/cjs/web/MockProviders.js +2 -1
  36. package/dist/cjs/web/MockRouter.d.ts +0 -3
  37. package/dist/cjs/web/MockRouter.d.ts.map +1 -1
  38. package/dist/cjs/web/globRoutesImporter.d.ts +13 -0
  39. package/dist/cjs/web/globRoutesImporter.d.ts.map +1 -0
  40. package/dist/cjs/web/globRoutesImporter.js +46 -0
  41. package/dist/cjs/web/vitest/index.d.ts +4 -0
  42. package/dist/cjs/web/vitest/index.d.ts.map +1 -0
  43. package/dist/cjs/web/vitest/index.js +34 -0
  44. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts +2 -0
  45. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts.map +1 -0
  46. package/dist/cjs/web/vitest/vite-plugin-auto-import.js +60 -0
  47. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +7 -0
  48. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +1 -0
  49. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +42 -0
  50. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts +3 -0
  51. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +1 -0
  52. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +43 -0
  53. package/dist/web/MockProviders.d.ts +0 -4
  54. package/dist/web/MockProviders.d.ts.map +1 -1
  55. package/dist/web/MockProviders.js +2 -1
  56. package/dist/web/MockRouter.d.ts +0 -3
  57. package/dist/web/MockRouter.d.ts.map +1 -1
  58. package/dist/web/globRoutesImporter.d.ts +13 -0
  59. package/dist/web/globRoutesImporter.d.ts.map +1 -0
  60. package/dist/web/globRoutesImporter.js +21 -0
  61. package/dist/web/vitest/index.d.ts +4 -0
  62. package/dist/web/vitest/index.d.ts.map +1 -0
  63. package/dist/web/vitest/index.js +8 -0
  64. package/dist/web/vitest/vite-plugin-auto-import.d.ts +2 -0
  65. package/dist/web/vitest/vite-plugin-auto-import.d.ts.map +1 -0
  66. package/dist/web/vitest/vite-plugin-auto-import.js +26 -0
  67. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +7 -0
  68. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +1 -0
  69. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.js +18 -0
  70. package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts +3 -0
  71. package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +1 -0
  72. package/dist/web/vitest/vite-plugin-create-auth-import-transform.js +19 -0
  73. package/package.json +39 -12
@@ -0,0 +1,60 @@
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var vite_plugin_auto_import_exports = {};
30
+ __export(vite_plugin_auto_import_exports, {
31
+ autoImportsPlugin: () => autoImportsPlugin
32
+ });
33
+ module.exports = __toCommonJS(vite_plugin_auto_import_exports);
34
+ var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
35
+ function autoImportsPlugin() {
36
+ return (0, import_vite.default)({
37
+ // targets to transform
38
+ include: [
39
+ /\.[tj]sx?$/
40
+ // .ts, .tsx, .js, .jsx
41
+ ],
42
+ // global imports to register
43
+ imports: [
44
+ {
45
+ "@cedarjs/testing/web": [
46
+ "mockGraphQLQuery",
47
+ "mockGraphQLMutation",
48
+ "mockCurrentUser"
49
+ ]
50
+ }
51
+ ],
52
+ // We provide our mocking types elsewhere and so don't need this plugin to
53
+ // generate them.
54
+ dts: false
55
+ });
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ autoImportsPlugin
60
+ });
@@ -0,0 +1,7 @@
1
+ import type { PluginOption } from 'vite';
2
+ /**
3
+ * Replace `@cedarjs/router` imports with imports of
4
+ * `@cedarjs/testing/web/MockRouter.js` instead
5
+ */
6
+ export declare function cedarJsRouterImportTransformPlugin(): PluginOption;
7
+ //# sourceMappingURL=vite-plugin-cedarjs-router-import-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-cedarjs-router-import-transform.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/vite-plugin-cedarjs-router-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;GAGG;AACH,wBAAgB,kCAAkC,IAAI,YAAY,CAejE"}
@@ -0,0 +1,42 @@
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 vite_plugin_cedarjs_router_import_transform_exports = {};
20
+ __export(vite_plugin_cedarjs_router_import_transform_exports, {
21
+ cedarJsRouterImportTransformPlugin: () => cedarJsRouterImportTransformPlugin
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedarjs_router_import_transform_exports);
24
+ function cedarJsRouterImportTransformPlugin() {
25
+ return {
26
+ name: "cedarjs-router-import-transform",
27
+ enforce: "pre",
28
+ transform(code, id) {
29
+ if (id.includes("/web/src")) {
30
+ code = code.replace(
31
+ /['"]@cedarjs\/router['"]/,
32
+ "'@cedarjs/testing/web/MockRouter.js'"
33
+ );
34
+ }
35
+ return code;
36
+ }
37
+ };
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ cedarJsRouterImportTransformPlugin
42
+ });
@@ -0,0 +1,3 @@
1
+ import type { PluginOption } from 'vite';
2
+ export declare function createAuthImportTransformPlugin(): PluginOption;
3
+ //# sourceMappingURL=vite-plugin-create-auth-import-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-create-auth-import-transform.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/vite-plugin-create-auth-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,wBAAgB,+BAA+B,IAAI,YAAY,CAuB9D"}
@@ -0,0 +1,43 @@
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 vite_plugin_create_auth_import_transform_exports = {};
20
+ __export(vite_plugin_create_auth_import_transform_exports, {
21
+ createAuthImportTransformPlugin: () => createAuthImportTransformPlugin
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_create_auth_import_transform_exports);
24
+ function createAuthImportTransformPlugin() {
25
+ return {
26
+ name: "create-auth-import-transform",
27
+ enforce: "pre",
28
+ transform(code, id) {
29
+ if (id.endsWith("/web/src/auth.ts") || id.endsWith("/web/src/auth.js")) {
30
+ code = code.replace(
31
+ /(^\s*import\s*{[^}]*?)(\bcreateAuth\b)(,?)([^}]*})/m,
32
+ "$1$4"
33
+ );
34
+ code = "import { createAuthentication as createAuth } from '@cedarjs/testing/auth'\n" + code;
35
+ }
36
+ return code;
37
+ }
38
+ };
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ createAuthImportTransformPlugin
43
+ });
@@ -1,7 +1,3 @@
1
- /**
2
- * NOTE: This module should not contain any nodejs functionality,
3
- * because it's also used by Storybook in the browser.
4
- */
5
1
  import React from 'react';
6
2
  export declare const MockProviders: React.FunctionComponent<{
7
3
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"MockProviders.d.ts","sourceRoot":"","sources":["../../src/web/MockProviders.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AA6BzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAWA,CAAA"}
1
+ {"version":3,"file":"MockProviders.d.ts","sourceRoot":"","sources":["../../src/web/MockProviders.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AA+BzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAYA,CAAA"}
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { LocationProvider } from "@cedarjs/router";
3
3
  import { RedwoodProvider } from "@cedarjs/web";
4
4
  import { RedwoodApolloProvider } from "@cedarjs/web/apollo";
5
+ import { UserRoutes as VitestUserRoutes } from "./globRoutesImporter.js";
5
6
  import { useAuth } from "./mockAuth.js";
6
7
  import { MockParamsProvider } from "./MockParamsProvider.js";
7
8
  let UserRoutes;
@@ -15,7 +16,7 @@ try {
15
16
  UserRoutes = () => /* @__PURE__ */ React.createElement(React.Fragment, null);
16
17
  }
17
18
  const MockProviders = ({ children }) => {
18
- return /* @__PURE__ */ React.createElement(RedwoodProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ React.createElement(RedwoodApolloProvider, { useAuth }, /* @__PURE__ */ React.createElement(UserRoutes, null), /* @__PURE__ */ React.createElement(LocationProvider, null, /* @__PURE__ */ React.createElement(MockParamsProvider, null, children))));
19
+ return /* @__PURE__ */ React.createElement(RedwoodProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ React.createElement(RedwoodApolloProvider, { useAuth }, /* @__PURE__ */ React.createElement(UserRoutes, null), /* @__PURE__ */ React.createElement(VitestUserRoutes, null), /* @__PURE__ */ React.createElement(LocationProvider, null, /* @__PURE__ */ React.createElement(MockParamsProvider, null, children))));
19
20
  };
20
21
  function isModuleNotFoundError(error, module) {
21
22
  return !!error && typeof error === "object" && "code" in error && error.code === "MODULE_NOT_FOUND" && "moduleName" in error && error.moduleName === module;
@@ -5,9 +5,6 @@ export declare const routes: {
5
5
  [routeName: string]: () => string;
6
6
  };
7
7
  /**
8
- * We overwrite the default `Router` export (see jest-preset). So every import
9
- * of @cedarjs/router will import this Router instead
10
- *
11
8
  * This router populates the `routes.<pageName>()` utility object.
12
9
  */
13
10
  export declare const Router: React.FC<RouterProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"MockRouter.d.ts","sourceRoot":"","sources":["../../src/web/MockRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAE9D,cAAc,4BAA4B,CAAA;AAE1C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,MAAM,CAAA;CAAO,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAcxC,CAAA"}
1
+ {"version":3,"file":"MockRouter.d.ts","sourceRoot":"","sources":["../../src/web/MockRouter.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAG9D,cAAc,4BAA4B,CAAA;AAE1C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,MAAM,CAAA;CAAO,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAcxC,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * All the routes the user has defined
3
+ *
4
+ * We render this in the `<MockProviders>` component to populate the `routes`
5
+ * import from `@cedarjs/router` to make sure code like
6
+ * `<Link to={routes.home()}>Home</Link>` works in tests
7
+ *
8
+ * The final piece to this puzzle is to realize that the user's Routes file
9
+ * imports `@cedarjs/router`, which we replace to import from '@cedarjs/testing'
10
+ * instead using a vite plugin that we only run for vitest and storybook
11
+ */
12
+ export declare const UserRoutes: React.FC;
13
+ //# sourceMappingURL=globRoutesImporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globRoutesImporter.d.ts","sourceRoot":"","sources":["../../src/web/globRoutesImporter.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAqB,KAAK,CAAC,EAAE,CAAA"}
@@ -0,0 +1,21 @@
1
+ const defaultExports = import.meta.glob(
2
+ ["/src/Routes.{tsx,jsx}", "/Routes.{tsx,jsx}"],
3
+ {
4
+ import: "default",
5
+ eager: true
6
+ }
7
+ );
8
+ const routesFileName = Object.keys(defaultExports)[0];
9
+ if (!routesFileName) {
10
+ throw new Error("@cedarjs/testing: No routes found");
11
+ }
12
+ const routesFunction = defaultExports[routesFileName];
13
+ if (typeof routesFunction !== "function") {
14
+ throw new Error(
15
+ "@cedarjs/testing: Routes file does not export a React component"
16
+ );
17
+ }
18
+ const UserRoutes = routesFunction;
19
+ export {
20
+ UserRoutes
21
+ };
@@ -0,0 +1,4 @@
1
+ export { cedarJsRouterImportTransformPlugin } from './vite-plugin-cedarjs-router-import-transform.js';
2
+ export { createAuthImportTransformPlugin } from './vite-plugin-create-auth-import-transform.js';
3
+ export { autoImportsPlugin } from './vite-plugin-auto-import.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,kDAAkD,CAAA;AACrG,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { cedarJsRouterImportTransformPlugin } from "./vite-plugin-cedarjs-router-import-transform.js";
2
+ import { createAuthImportTransformPlugin } from "./vite-plugin-create-auth-import-transform.js";
3
+ import { autoImportsPlugin } from "./vite-plugin-auto-import.js";
4
+ export {
5
+ autoImportsPlugin,
6
+ cedarJsRouterImportTransformPlugin,
7
+ createAuthImportTransformPlugin
8
+ };
@@ -0,0 +1,2 @@
1
+ export declare function autoImportsPlugin(): import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
+ //# sourceMappingURL=vite-plugin-auto-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-auto-import.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/vite-plugin-auto-import.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,8DAsBhC"}
@@ -0,0 +1,26 @@
1
+ import autoImport from "unplugin-auto-import/vite";
2
+ function autoImportsPlugin() {
3
+ return autoImport({
4
+ // targets to transform
5
+ include: [
6
+ /\.[tj]sx?$/
7
+ // .ts, .tsx, .js, .jsx
8
+ ],
9
+ // global imports to register
10
+ imports: [
11
+ {
12
+ "@cedarjs/testing/web": [
13
+ "mockGraphQLQuery",
14
+ "mockGraphQLMutation",
15
+ "mockCurrentUser"
16
+ ]
17
+ }
18
+ ],
19
+ // We provide our mocking types elsewhere and so don't need this plugin to
20
+ // generate them.
21
+ dts: false
22
+ });
23
+ }
24
+ export {
25
+ autoImportsPlugin
26
+ };
@@ -0,0 +1,7 @@
1
+ import type { PluginOption } from 'vite';
2
+ /**
3
+ * Replace `@cedarjs/router` imports with imports of
4
+ * `@cedarjs/testing/web/MockRouter.js` instead
5
+ */
6
+ export declare function cedarJsRouterImportTransformPlugin(): PluginOption;
7
+ //# sourceMappingURL=vite-plugin-cedarjs-router-import-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-cedarjs-router-import-transform.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/vite-plugin-cedarjs-router-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;GAGG;AACH,wBAAgB,kCAAkC,IAAI,YAAY,CAejE"}
@@ -0,0 +1,18 @@
1
+ function cedarJsRouterImportTransformPlugin() {
2
+ return {
3
+ name: "cedarjs-router-import-transform",
4
+ enforce: "pre",
5
+ transform(code, id) {
6
+ if (id.includes("/web/src")) {
7
+ code = code.replace(
8
+ /['"]@cedarjs\/router['"]/,
9
+ "'@cedarjs/testing/web/MockRouter.js'"
10
+ );
11
+ }
12
+ return code;
13
+ }
14
+ };
15
+ }
16
+ export {
17
+ cedarJsRouterImportTransformPlugin
18
+ };
@@ -0,0 +1,3 @@
1
+ import type { PluginOption } from 'vite';
2
+ export declare function createAuthImportTransformPlugin(): PluginOption;
3
+ //# sourceMappingURL=vite-plugin-create-auth-import-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-create-auth-import-transform.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/vite-plugin-create-auth-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,wBAAgB,+BAA+B,IAAI,YAAY,CAuB9D"}
@@ -0,0 +1,19 @@
1
+ function createAuthImportTransformPlugin() {
2
+ return {
3
+ name: "create-auth-import-transform",
4
+ enforce: "pre",
5
+ transform(code, id) {
6
+ if (id.endsWith("/web/src/auth.ts") || id.endsWith("/web/src/auth.js")) {
7
+ code = code.replace(
8
+ /(^\s*import\s*{[^}]*?)(\bcreateAuth\b)(,?)([^}]*})/m,
9
+ "$1$4"
10
+ );
11
+ code = "import { createAuthentication as createAuth } from '@cedarjs/testing/auth'\n" + code;
12
+ }
13
+ return code;
14
+ }
15
+ };
16
+ }
17
+ export {
18
+ createAuthImportTransformPlugin
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/testing",
3
- "version": "0.7.2-next.2+30d6c0c8c",
3
+ "version": "0.7.2-next.49+eaf36e897",
4
4
  "description": "Tools, wrappers and configuration for testing a CedarJS project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,6 +63,10 @@
63
63
  "default": "./dist/cjs/api/index.js"
64
64
  }
65
65
  },
66
+ "./api/vitest": {
67
+ "types": "./dist/api/vitest/index.d.ts",
68
+ "default": "./dist/api/vitest/index.js"
69
+ },
66
70
  "./cache": {
67
71
  "import": {
68
72
  "types": "./dist/cache/index.d.ts",
@@ -82,6 +86,20 @@
82
86
  "types": "./dist/cjs/web/index.d.ts",
83
87
  "default": "./dist/cjs/web/index.js"
84
88
  }
89
+ },
90
+ "./web/MockRouter.js": {
91
+ "import": {
92
+ "types": "./dist/web/MockRouter.d.ts",
93
+ "default": "./dist/web/MockRouter.js"
94
+ },
95
+ "require": {
96
+ "types": "./dist/cjs/web/MockRouter.d.ts",
97
+ "default": "./dist/cjs/web/MockRouter.js"
98
+ }
99
+ },
100
+ "./web/vitest": {
101
+ "types": "./dist/web/vitest/index.d.ts",
102
+ "default": "./dist/web/vitest/index.js"
85
103
  }
86
104
  },
87
105
  "files": [
@@ -95,7 +113,7 @@
95
113
  "build": "tsx ./build.mts && yarn build:types",
96
114
  "build:pack": "yarn pack -o cedarjs-testing.tgz",
97
115
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
98
- "build:types-cjs": "tsc --build --verbose tsconfig.cjs.json",
116
+ "build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
99
117
  "build:watch": "nodemon --watch src --ext 'js,jsx,ts,tsx' --ignore dist --exec 'yarn build'",
100
118
  "check:attw": "yarn rw-fwtools-attw",
101
119
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -104,13 +122,13 @@
104
122
  "test:watch": "vitest watch"
105
123
  },
106
124
  "dependencies": {
107
- "@cedarjs/auth": "0.7.2-next.2+30d6c0c8c",
108
- "@cedarjs/babel-config": "0.7.2-next.2+30d6c0c8c",
109
- "@cedarjs/context": "0.7.2-next.2+30d6c0c8c",
110
- "@cedarjs/graphql-server": "0.7.2-next.2+30d6c0c8c",
111
- "@cedarjs/project-config": "0.7.2-next.2+30d6c0c8c",
112
- "@cedarjs/router": "0.7.2-next.2+30d6c0c8c",
113
- "@cedarjs/web": "0.7.2-next.2+30d6c0c8c",
125
+ "@cedarjs/auth": "0.7.2-next.49+eaf36e897",
126
+ "@cedarjs/babel-config": "0.7.2-next.49+eaf36e897",
127
+ "@cedarjs/context": "0.7.2-next.49+eaf36e897",
128
+ "@cedarjs/graphql-server": "0.7.2-next.49+eaf36e897",
129
+ "@cedarjs/project-config": "0.7.2-next.49+eaf36e897",
130
+ "@cedarjs/router": "0.7.2-next.49+eaf36e897",
131
+ "@cedarjs/web": "0.7.2-next.49+eaf36e897",
114
132
  "@testing-library/jest-dom": "6.5.0",
115
133
  "@testing-library/react": "14.3.1",
116
134
  "@testing-library/user-event": "14.5.2",
@@ -125,19 +143,28 @@
125
143
  "jest-watch-typeahead": "2.2.2",
126
144
  "msw": "1.3.5",
127
145
  "ts-toolbelt": "9.6.0",
146
+ "unplugin-auto-import": "19.3.0",
128
147
  "whatwg-fetch": "3.6.20"
129
148
  },
130
149
  "devDependencies": {
131
- "@cedarjs/framework-tools": "0.7.2-next.2",
150
+ "@cedarjs/framework-tools": "0.7.2-next.49",
132
151
  "concurrently": "8.2.2",
133
152
  "jsdom": "24.1.3",
134
153
  "publint": "0.3.12",
135
- "tsx": "4.20.3",
154
+ "tsx": "4.20.4",
136
155
  "typescript": "5.6.2",
137
156
  "vitest": "3.2.4"
138
157
  },
158
+ "peerDependencies": {
159
+ "vitest": "3.2.4"
160
+ },
161
+ "peerDependenciesMeta": {
162
+ "vitest": {
163
+ "optional": true
164
+ }
165
+ },
139
166
  "publishConfig": {
140
167
  "access": "public"
141
168
  },
142
- "gitHead": "30d6c0c8c64f48a0ecd4acdb5a52dc7c6db19c42"
169
+ "gitHead": "eaf36e897609e775295faca150fe4a3b448841e3"
143
170
  }