@cedarjs/testing 1.0.0-canary.12570 → 1.0.0-canary.12571

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 (71) hide show
  1. package/dist/cjs/web/MockProviders.d.ts +4 -0
  2. package/dist/cjs/web/MockProviders.d.ts.map +1 -1
  3. package/dist/cjs/web/MockProviders.js +1 -2
  4. package/dist/cjs/web/MockRouter.d.ts +3 -0
  5. package/dist/cjs/web/MockRouter.d.ts.map +1 -1
  6. package/dist/web/MockProviders.d.ts +4 -0
  7. package/dist/web/MockProviders.d.ts.map +1 -1
  8. package/dist/web/MockProviders.js +1 -2
  9. package/dist/web/MockRouter.d.ts +3 -0
  10. package/dist/web/MockRouter.d.ts.map +1 -1
  11. package/package.json +11 -30
  12. package/dist/api/mockContext.d.ts +0 -5
  13. package/dist/api/mockContext.d.ts.map +0 -1
  14. package/dist/api/mockContext.js +0 -33
  15. package/dist/api/vitest/CedarApiVitestEnv.d.ts +0 -5
  16. package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +0 -1
  17. package/dist/api/vitest/CedarApiVitestEnv.js +0 -41
  18. package/dist/api/vitest/index.d.ts +0 -4
  19. package/dist/api/vitest/index.d.ts.map +0 -1
  20. package/dist/api/vitest/index.js +0 -8
  21. package/dist/api/vitest/vite-plugin-auto-import.d.ts +0 -2
  22. package/dist/api/vitest/vite-plugin-auto-import.d.ts.map +0 -1
  23. package/dist/api/vitest/vite-plugin-auto-import.js +0 -37
  24. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts +0 -3
  25. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +0 -1
  26. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -34
  27. package/dist/api/vitest/vite-plugin-track-db-imports.d.ts +0 -3
  28. package/dist/api/vitest/vite-plugin-track-db-imports.d.ts.map +0 -1
  29. package/dist/api/vitest/vite-plugin-track-db-imports.js +0 -23
  30. package/dist/api/vitest/vitest-api.setup.d.ts +0 -9
  31. package/dist/api/vitest/vitest-api.setup.d.ts.map +0 -1
  32. package/dist/api/vitest/vitest-api.setup.js +0 -247
  33. package/dist/cjs/api/mockContext.d.ts +0 -5
  34. package/dist/cjs/api/mockContext.d.ts.map +0 -1
  35. package/dist/cjs/api/mockContext.js +0 -58
  36. package/dist/cjs/api/vitest/CedarApiVitestEnv.js +0 -71
  37. package/dist/cjs/api/vitest/index.js +0 -34
  38. package/dist/cjs/api/vitest/vite-plugin-auto-import.js +0 -71
  39. package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -69
  40. package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +0 -47
  41. package/dist/cjs/api/vitest/vitest-api.setup.js +0 -270
  42. package/dist/cjs/web/globRoutesImporter.d.ts +0 -13
  43. package/dist/cjs/web/globRoutesImporter.d.ts.map +0 -1
  44. package/dist/cjs/web/globRoutesImporter.js +0 -46
  45. package/dist/cjs/web/vitest/index.d.ts +0 -4
  46. package/dist/cjs/web/vitest/index.d.ts.map +0 -1
  47. package/dist/cjs/web/vitest/index.js +0 -34
  48. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts +0 -2
  49. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts.map +0 -1
  50. package/dist/cjs/web/vitest/vite-plugin-auto-import.js +0 -60
  51. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +0 -7
  52. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +0 -1
  53. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -42
  54. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts +0 -3
  55. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +0 -1
  56. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +0 -43
  57. package/dist/web/globRoutesImporter.d.ts +0 -13
  58. package/dist/web/globRoutesImporter.d.ts.map +0 -1
  59. package/dist/web/globRoutesImporter.js +0 -21
  60. package/dist/web/vitest/index.d.ts +0 -4
  61. package/dist/web/vitest/index.d.ts.map +0 -1
  62. package/dist/web/vitest/index.js +0 -8
  63. package/dist/web/vitest/vite-plugin-auto-import.d.ts +0 -2
  64. package/dist/web/vitest/vite-plugin-auto-import.d.ts.map +0 -1
  65. package/dist/web/vitest/vite-plugin-auto-import.js +0 -26
  66. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +0 -7
  67. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +0 -1
  68. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -18
  69. package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts +0 -3
  70. package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +0 -1
  71. package/dist/web/vitest/vite-plugin-create-auth-import-transform.js +0 -19
@@ -1,3 +1,7 @@
1
+ /**
2
+ * NOTE: This module should not contain any nodejs functionality,
3
+ * because it's also used by Storybook in the browser.
4
+ */
1
5
  import React from 'react';
2
6
  export declare const MockProviders: React.FunctionComponent<{
3
7
  children: React.ReactNode;
@@ -1 +1 @@
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"}
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"}
@@ -35,7 +35,6 @@ var import_react = __toESM(require("react"), 1);
35
35
  var import_router = require("@cedarjs/router");
36
36
  var import_web = require("@cedarjs/web");
37
37
  var import_apollo = require("@cedarjs/web/apollo");
38
- var import_globRoutesImporter = require("./globRoutesImporter.js");
39
38
  var import_mockAuth = require("./mockAuth.js");
40
39
  var import_MockParamsProvider = require("./MockParamsProvider.js");
41
40
  let UserRoutes;
@@ -49,7 +48,7 @@ try {
49
48
  UserRoutes = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
50
49
  }
51
50
  const MockProviders = ({ children }) => {
52
- return /* @__PURE__ */ import_react.default.createElement(import_web.RedwoodProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ import_react.default.createElement(import_apollo.RedwoodApolloProvider, { useAuth: import_mockAuth.useAuth }, /* @__PURE__ */ import_react.default.createElement(UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_globRoutesImporter.UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_router.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(import_MockParamsProvider.MockParamsProvider, null, children))));
51
+ return /* @__PURE__ */ import_react.default.createElement(import_web.RedwoodProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ import_react.default.createElement(import_apollo.RedwoodApolloProvider, { useAuth: import_mockAuth.useAuth }, /* @__PURE__ */ import_react.default.createElement(UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_router.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(import_MockParamsProvider.MockParamsProvider, null, children))));
53
52
  };
54
53
  function isModuleNotFoundError(error, module2) {
55
54
  return !!error && typeof error === "object" && "code" in error && error.code === "MODULE_NOT_FOUND" && "moduleName" in error && error.moduleName === module2;
@@ -5,6 +5,9 @@ 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
+ *
8
11
  * This router populates the `routes.<pageName>()` utility object.
9
12
  */
10
13
  export declare const Router: React.FC<RouterProps>;
@@ -1 +1 @@
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"}
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,3 +1,7 @@
1
+ /**
2
+ * NOTE: This module should not contain any nodejs functionality,
3
+ * because it's also used by Storybook in the browser.
4
+ */
1
5
  import React from 'react';
2
6
  export declare const MockProviders: React.FunctionComponent<{
3
7
  children: React.ReactNode;
@@ -1 +1 @@
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"}
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"}
@@ -2,7 +2,6 @@ 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";
6
5
  import { useAuth } from "./mockAuth.js";
7
6
  import { MockParamsProvider } from "./MockParamsProvider.js";
8
7
  let UserRoutes;
@@ -16,7 +15,7 @@ try {
16
15
  UserRoutes = () => /* @__PURE__ */ React.createElement(React.Fragment, null);
17
16
  }
18
17
  const MockProviders = ({ 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))));
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))));
20
19
  };
21
20
  function isModuleNotFoundError(error, module) {
22
21
  return !!error && typeof error === "object" && "code" in error && error.code === "MODULE_NOT_FOUND" && "moduleName" in error && error.moduleName === module;
@@ -5,6 +5,9 @@ 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
+ *
8
11
  * This router populates the `routes.<pageName>()` utility object.
9
12
  */
10
13
  export declare const Router: React.FC<RouterProps>;
@@ -1 +1 @@
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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/testing",
3
- "version": "1.0.0-canary.12570+dff550139",
3
+ "version": "1.0.0-canary.12571+cf3af7f37",
4
4
  "description": "Tools, wrappers and configuration for testing a Cedar project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,10 +63,6 @@
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
- },
70
66
  "./cache": {
71
67
  "import": {
72
68
  "types": "./dist/cache/index.d.ts",
@@ -86,20 +82,6 @@
86
82
  "types": "./dist/cjs/web/index.d.ts",
87
83
  "default": "./dist/cjs/web/index.js"
88
84
  }
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"
103
85
  }
104
86
  },
105
87
  "files": [
@@ -113,7 +95,7 @@
113
95
  "build": "tsx ./build.mts && yarn build:types",
114
96
  "build:pack": "yarn pack -o cedarjs-testing.tgz",
115
97
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
116
- "build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
98
+ "build:types-cjs": "tsc --build --verbose tsconfig.cjs.json",
117
99
  "build:watch": "nodemon --watch src --ext 'js,jsx,ts,tsx' --ignore dist --exec 'yarn build'",
118
100
  "check:attw": "yarn rw-fwtools-attw",
119
101
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -122,13 +104,13 @@
122
104
  "test:watch": "vitest watch"
123
105
  },
124
106
  "dependencies": {
125
- "@cedarjs/auth": "1.0.0-canary.12570",
126
- "@cedarjs/babel-config": "1.0.0-canary.12570",
127
- "@cedarjs/context": "1.0.0-canary.12570",
128
- "@cedarjs/graphql-server": "1.0.0-canary.12570",
129
- "@cedarjs/project-config": "1.0.0-canary.12570",
130
- "@cedarjs/router": "1.0.0-canary.12570",
131
- "@cedarjs/web": "1.0.0-canary.12570",
107
+ "@cedarjs/auth": "1.0.0-canary.12571",
108
+ "@cedarjs/babel-config": "1.0.0-canary.12571",
109
+ "@cedarjs/context": "1.0.0-canary.12571",
110
+ "@cedarjs/graphql-server": "1.0.0-canary.12571",
111
+ "@cedarjs/project-config": "1.0.0-canary.12571",
112
+ "@cedarjs/router": "1.0.0-canary.12571",
113
+ "@cedarjs/web": "1.0.0-canary.12571",
132
114
  "@testing-library/jest-dom": "6.5.0",
133
115
  "@testing-library/react": "14.3.1",
134
116
  "@testing-library/user-event": "14.5.2",
@@ -143,11 +125,10 @@
143
125
  "jest-watch-typeahead": "2.2.2",
144
126
  "msw": "1.3.5",
145
127
  "ts-toolbelt": "9.6.0",
146
- "unplugin-auto-import": "19.3.0",
147
128
  "whatwg-fetch": "3.6.20"
148
129
  },
149
130
  "devDependencies": {
150
- "@cedarjs/framework-tools": "1.0.0-canary.12570",
131
+ "@cedarjs/framework-tools": "1.0.0-canary.12571",
151
132
  "concurrently": "8.2.2",
152
133
  "jsdom": "24.1.3",
153
134
  "publint": "0.3.12",
@@ -155,5 +136,5 @@
155
136
  "typescript": "5.6.2",
156
137
  "vitest": "3.2.4"
157
138
  },
158
- "gitHead": "dff550139281a148d56c9100a0bebd85c4fbc2ee"
139
+ "gitHead": "cf3af7f3761db597a930b9297c023e6d78662452"
159
140
  }
@@ -1,5 +0,0 @@
1
- export interface GlobalContext extends Record<string, unknown> {
2
- }
3
- export declare const context: {};
4
- export declare const setContext: (newContext: GlobalContext) => GlobalContext;
5
- //# sourceMappingURL=mockContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockContext.d.ts","sourceRoot":"","sources":["../../src/api/mockContext.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEjE,eAAO,MAAM,OAAO,IAAc,CAAA;AAElC,eAAO,MAAM,UAAU,eAAgB,aAAa,KAAG,aAKtD,CAAA"}
@@ -1,33 +0,0 @@
1
- const mockContextStore = /* @__PURE__ */ new Map();
2
- const mockContext = new Proxy(
3
- {},
4
- {
5
- get: (_target, prop) => {
6
- if (prop === "toJSON") {
7
- return () => mockContextStore.get("context");
8
- }
9
- const ctx = mockContextStore.get("context");
10
- if (!ctx) {
11
- return void 0;
12
- }
13
- return ctx[prop];
14
- },
15
- set: (_target, prop, value) => {
16
- const ctx = mockContextStore.get("context");
17
- if (!ctx) {
18
- return false;
19
- }
20
- ctx[prop] = value;
21
- return true;
22
- }
23
- }
24
- );
25
- const context = mockContext;
26
- const setContext = (newContext) => {
27
- mockContextStore.set("context", newContext);
28
- return mockContext;
29
- };
30
- export {
31
- context,
32
- setContext
33
- };
@@ -1,5 +0,0 @@
1
- import 'dotenv-defaults/config.js';
2
- import type { Environment } from 'vitest/environments';
3
- declare const CedarApiVitestEnvironment: Environment;
4
- export default CedarApiVitestEnvironment;
5
- //# sourceMappingURL=CedarApiVitestEnv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CedarApiVitestEnv.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/CedarApiVitestEnv.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAMtD,QAAA,MAAM,yBAAyB,EAAE,WA+ChC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
@@ -1,41 +0,0 @@
1
- import { getSchema } from "@prisma/internals";
2
- import "dotenv-defaults/config.js";
3
- import execa from "execa";
4
- import { getPaths } from "@cedarjs/project-config";
5
- import { getDefaultDb, checkAndReplaceDirectUrl } from "../directUrlHelpers.js";
6
- const CedarApiVitestEnvironment = {
7
- name: "cedar-api",
8
- transformMode: "ssr",
9
- async setup() {
10
- if (process.env.SKIP_DB_PUSH === "1") {
11
- return {
12
- teardown() {
13
- }
14
- };
15
- }
16
- const cedarPaths = getPaths();
17
- const defaultDb = getDefaultDb(cedarPaths.base);
18
- process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
19
- const prismaSchema = (await getSchema(cedarPaths.api.dbSchema)).toString();
20
- const directUrlEnvVar = checkAndReplaceDirectUrl(prismaSchema, defaultDb);
21
- const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
22
- const directUrlDefinition = directUrlEnvVar ? { [directUrlEnvVar]: process.env[directUrlEnvVar] } : {};
23
- execa.sync(`yarn rw`, command, {
24
- cwd: cedarPaths.api.base,
25
- stdio: "inherit",
26
- shell: true,
27
- env: {
28
- DATABASE_URL: process.env.DATABASE_URL,
29
- ...directUrlDefinition
30
- }
31
- });
32
- return {
33
- teardown() {
34
- }
35
- };
36
- }
37
- };
38
- var CedarApiVitestEnv_default = CedarApiVitestEnvironment;
39
- export {
40
- CedarApiVitestEnv_default as default
41
- };
@@ -1,4 +0,0 @@
1
- export { autoImportsPlugin } from './vite-plugin-auto-import.js';
2
- export { cedarVitestApiConfigPlugin } from './vite-plugin-cedar-vitest-api-config.js';
3
- export { trackDbImportsPlugin } from './vite-plugin-track-db-imports.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA"}
@@ -1,8 +0,0 @@
1
- import { autoImportsPlugin } from "./vite-plugin-auto-import.js";
2
- import { cedarVitestApiConfigPlugin } from "./vite-plugin-cedar-vitest-api-config.js";
3
- import { trackDbImportsPlugin } from "./vite-plugin-track-db-imports.js";
4
- export {
5
- autoImportsPlugin,
6
- cedarVitestApiConfigPlugin,
7
- trackDbImportsPlugin
8
- };
@@ -1,2 +0,0 @@
1
- export declare function autoImportsPlugin(): import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
- //# sourceMappingURL=vite-plugin-auto-import.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin-auto-import.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/vite-plugin-auto-import.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,8DAiChC"}
@@ -1,37 +0,0 @@
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
- // import { mockContext, mockHttpEvent, mockSignedWebhook } from '@cedarjs/testing/api';
12
- {
13
- "@cedarjs/testing/api": [
14
- "mockContext",
15
- "mockHttpEvent",
16
- "mockSignedWebhook"
17
- ]
18
- },
19
- // import { gql } from 'graphql-tag'
20
- {
21
- "graphql-tag": ["gql"]
22
- },
23
- // import { context } from '@cedarjs/context'
24
- {
25
- "@cedarjs/context": ["context"]
26
- }
27
- ],
28
- // We provide our mocking types elsewhere and so don't need this plugin to
29
- // generate them.
30
- // TODO: Maybe we should have it at least generate the types for the gql
31
- // import? (Or do we already provide that some other way?)
32
- dts: false
33
- });
34
- }
35
- export {
36
- autoImportsPlugin
37
- };
@@ -1,3 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- export declare function cedarVitestApiConfigPlugin(): Plugin;
3
- //# sourceMappingURL=vite-plugin-cedar-vitest-api-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin-cedar-vitest-api-config.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/vite-plugin-cedar-vitest-api-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,wBAAgB,0BAA0B,IAAI,MAAM,CA4BnD"}
@@ -1,34 +0,0 @@
1
- import path from "node:path";
2
- import { getEnvVarDefinitions, getPaths } from "@cedarjs/project-config";
3
- function cedarVitestApiConfigPlugin() {
4
- return {
5
- name: "cedar-vitest-plugin",
6
- config: () => {
7
- return {
8
- define: getEnvVarDefinitions(),
9
- ssr: {
10
- noExternal: ["@cedarjs/testing"]
11
- },
12
- resolve: {
13
- alias: {
14
- src: getPaths().api.src
15
- }
16
- },
17
- test: {
18
- environment: path.join(import.meta.dirname, "CedarApiVitestEnv.js"),
19
- // fileParallelism: false,
20
- // fileParallelism doesn't work with vitest projects (which is what
21
- // we're using in the root vitest.config.ts). As a workaround we set
22
- // poolOptions instead, which also shouldn't work, but was suggested
23
- // by Vitest team member AriPerkkio (Hiroshi's answer didn't work).
24
- // https://github.com/vitest-dev/vitest/discussions/7416
25
- poolOptions: { forks: { singleFork: true } },
26
- setupFiles: [path.join(import.meta.dirname, "vitest-api.setup.js")]
27
- }
28
- };
29
- }
30
- };
31
- }
32
- export {
33
- cedarVitestApiConfigPlugin
34
- };
@@ -1,3 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- export declare function trackDbImportsPlugin(): Plugin;
3
- //# sourceMappingURL=vite-plugin-track-db-imports.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin-track-db-imports.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/vite-plugin-track-db-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,wBAAgB,oBAAoB,IAAI,MAAM,CA8B7C"}
@@ -1,23 +0,0 @@
1
- function trackDbImportsPlugin() {
2
- return {
3
- name: "db-import-tracker",
4
- transform(code, id) {
5
- if (id.match(/\/api\/src\/lib\/db\.(js|ts)$/) && code.includes("PrismaClient")) {
6
- return code + `
7
- ;if (typeof globalThis !== "undefined") {
8
- globalThis.__cedarjs_db_imported__ = true;
9
- } else {
10
- throw new Error(
11
- "vite-plugin-track-db-imports: globalThis is undefined. " +
12
- "This is an error with CedarJS"
13
- );
14
- }
15
- `;
16
- }
17
- return code;
18
- }
19
- };
20
- }
21
- export {
22
- trackDbImportsPlugin
23
- };
@@ -1,9 +0,0 @@
1
- import type { DefineScenario } from '@cedarjs/testing/api';
2
- declare global {
3
- var mockCurrentUser: (currentUser: Record<string, unknown> | null) => void;
4
- }
5
- declare global {
6
- var defineScenario: DefineScenario;
7
- var __cedarjs_db_imported__: boolean;
8
- }
9
- //# sourceMappingURL=vitest-api.setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vitest-api.setup.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/vitest-api.setup.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AA0C1D,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,eAAe,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;CAC3E;AAUD,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,cAAc,EAAE,cAAc,CAAA;IAElC,IAAI,uBAAuB,EAAE,OAAO,CAAA;CACrC"}