@cedarjs/testing 0.6.1-next.0 → 0.6.1-next.51

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 (151) hide show
  1. package/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
  2. package/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
  3. package/config/jest/api/RedwoodApiJestEnv.js +33 -16
  4. package/config/jest/api/apiBabelConfig.d.ts +5 -0
  5. package/config/jest/api/apiBabelConfig.d.ts.map +1 -0
  6. package/config/jest/api/apiBabelConfig.js +33 -17
  7. package/config/jest/api/globalSetup.d.ts +3 -0
  8. package/config/jest/api/globalSetup.d.ts.map +1 -0
  9. package/config/jest/api/globalSetup.js +59 -44
  10. package/config/jest/api/index.d.ts +3 -0
  11. package/config/jest/api/index.d.ts.map +1 -0
  12. package/config/jest/api/index.js +25 -2
  13. package/config/jest/api/jest-preset.d.ts +4 -0
  14. package/config/jest/api/jest-preset.d.ts.map +1 -0
  15. package/config/jest/api/jest-preset.js +69 -39
  16. package/config/jest/api/jest.setup.d.ts +2 -0
  17. package/config/jest/api/jest.setup.d.ts.map +1 -0
  18. package/config/jest/api/jest.setup.js +189 -248
  19. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
  20. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  21. package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +103 -124
  22. package/config/jest/jest-serial-runner.d.ts +8 -0
  23. package/config/jest/jest-serial-runner.d.ts.map +1 -0
  24. package/config/jest/jest-serial-runner.js +33 -9
  25. package/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
  26. package/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
  27. package/config/jest/web/RedwoodWebJestEnv.js +33 -12
  28. package/config/jest/web/index.d.ts +3 -0
  29. package/config/jest/web/index.d.ts.map +1 -0
  30. package/config/jest/web/index.js +25 -2
  31. package/config/jest/web/jest-preset.d.ts +4 -0
  32. package/config/jest/web/jest-preset.d.ts.map +1 -0
  33. package/config/jest/web/jest-preset.js +78 -50
  34. package/config/jest/web/jest.setup.d.ts +8 -0
  35. package/config/jest/web/jest.setup.d.ts.map +1 -0
  36. package/config/jest/web/jest.setup.js +17 -36
  37. package/config/jest/web/resolver.d.ts +4 -0
  38. package/config/jest/web/resolver.d.ts.map +1 -0
  39. package/config/jest/web/resolver.js +24 -31
  40. package/config/jest/web/webBabelConfig.d.ts +10 -0
  41. package/config/jest/web/webBabelConfig.d.ts.map +1 -0
  42. package/config/jest/web/webBabelConfig.js +43 -13
  43. package/config/package.json +1 -0
  44. package/dist/api/directUrlHelpers.d.ts.map +1 -1
  45. package/dist/api/index.d.ts +1 -0
  46. package/dist/api/index.d.ts.map +1 -1
  47. package/dist/api/index.js +1 -0
  48. package/dist/cjs/api/directUrlHelpers.d.ts.map +1 -1
  49. package/dist/cjs/api/index.d.ts +1 -0
  50. package/dist/cjs/api/index.d.ts.map +1 -1
  51. package/dist/cjs/api/index.js +3 -1
  52. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
  53. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
  54. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +48 -0
  55. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +5 -0
  56. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +1 -0
  57. package/dist/cjs/config/jest/api/apiBabelConfig.js +34 -0
  58. package/dist/cjs/config/jest/api/globalSetup.d.ts +3 -0
  59. package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -0
  60. package/dist/cjs/config/jest/api/globalSetup.js +61 -0
  61. package/dist/cjs/config/jest/api/index.d.ts +3 -0
  62. package/dist/cjs/config/jest/api/index.d.ts.map +1 -0
  63. package/dist/cjs/config/jest/api/index.js +25 -0
  64. package/dist/cjs/config/jest/api/jest-preset.d.ts +4 -0
  65. package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -0
  66. package/dist/cjs/config/jest/api/jest-preset.js +97 -0
  67. package/dist/cjs/config/jest/api/jest.setup.d.ts +2 -0
  68. package/dist/cjs/config/jest/api/jest.setup.d.ts.map +1 -0
  69. package/dist/cjs/config/jest/api/jest.setup.js +267 -0
  70. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
  71. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  72. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +121 -0
  73. package/dist/cjs/config/jest/jest-serial-runner.d.ts +8 -0
  74. package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +1 -0
  75. package/dist/cjs/config/jest/jest-serial-runner.js +37 -0
  76. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
  77. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
  78. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +38 -0
  79. package/dist/cjs/config/jest/web/index.d.ts +3 -0
  80. package/dist/cjs/config/jest/web/index.d.ts.map +1 -0
  81. package/dist/cjs/config/jest/web/index.js +25 -0
  82. package/dist/cjs/config/jest/web/jest-preset.d.ts +4 -0
  83. package/dist/cjs/config/jest/web/jest-preset.d.ts.map +1 -0
  84. package/dist/cjs/config/jest/web/jest-preset.js +117 -0
  85. package/dist/cjs/config/jest/web/jest.setup.d.ts +8 -0
  86. package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -0
  87. package/dist/cjs/config/jest/web/jest.setup.js +22 -0
  88. package/dist/cjs/config/jest/web/resolver.d.ts +4 -0
  89. package/dist/cjs/config/jest/web/resolver.d.ts.map +1 -0
  90. package/dist/cjs/config/jest/web/resolver.js +30 -0
  91. package/dist/cjs/config/jest/web/webBabelConfig.d.ts +10 -0
  92. package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +1 -0
  93. package/dist/cjs/config/jest/web/webBabelConfig.js +48 -0
  94. package/dist/cjs/web/global.d.ts +2 -2
  95. package/dist/cjs/web/global.d.ts.map +1 -1
  96. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
  97. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
  98. package/dist/config/jest/api/RedwoodApiJestEnv.js +28 -0
  99. package/dist/config/jest/api/apiBabelConfig.d.ts +5 -0
  100. package/dist/config/jest/api/apiBabelConfig.d.ts.map +1 -0
  101. package/dist/config/jest/api/apiBabelConfig.js +18 -0
  102. package/dist/config/jest/api/globalSetup.d.ts +3 -0
  103. package/dist/config/jest/api/globalSetup.d.ts.map +1 -0
  104. package/dist/config/jest/api/globalSetup.js +34 -0
  105. package/dist/config/jest/api/index.d.ts +3 -0
  106. package/dist/config/jest/api/index.d.ts.map +1 -0
  107. package/dist/config/jest/api/index.js +11 -0
  108. package/dist/config/jest/api/jest-preset.d.ts +4 -0
  109. package/dist/config/jest/api/jest-preset.d.ts.map +1 -0
  110. package/dist/config/jest/api/jest-preset.js +67 -0
  111. package/dist/config/jest/api/jest.setup.d.ts +2 -0
  112. package/dist/config/jest/api/jest.setup.d.ts.map +1 -0
  113. package/dist/config/jest/api/jest.setup.js +244 -0
  114. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
  115. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  116. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +101 -0
  117. package/dist/config/jest/jest-serial-runner.d.ts +8 -0
  118. package/dist/config/jest/jest-serial-runner.d.ts.map +1 -0
  119. package/dist/config/jest/jest-serial-runner.js +23 -0
  120. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
  121. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
  122. package/dist/config/jest/web/RedwoodWebJestEnv.js +18 -0
  123. package/dist/config/jest/web/index.d.ts +3 -0
  124. package/dist/config/jest/web/index.d.ts.map +1 -0
  125. package/dist/config/jest/web/index.js +11 -0
  126. package/dist/config/jest/web/jest-preset.d.ts +4 -0
  127. package/dist/config/jest/web/jest-preset.d.ts.map +1 -0
  128. package/dist/config/jest/web/jest-preset.js +87 -0
  129. package/dist/config/jest/web/jest.setup.d.ts +8 -0
  130. package/dist/config/jest/web/jest.setup.d.ts.map +1 -0
  131. package/dist/config/jest/web/jest.setup.js +28 -0
  132. package/dist/config/jest/web/resolver.d.ts +4 -0
  133. package/dist/config/jest/web/resolver.d.ts.map +1 -0
  134. package/dist/config/jest/web/resolver.js +38 -0
  135. package/dist/config/jest/web/webBabelConfig.d.ts +10 -0
  136. package/dist/config/jest/web/webBabelConfig.d.ts.map +1 -0
  137. package/dist/config/jest/web/webBabelConfig.js +18 -0
  138. package/dist/web/global.d.ts +2 -2
  139. package/dist/web/global.d.ts.map +1 -1
  140. package/package.json +20 -11
  141. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/code.js +0 -28
  142. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/output.js +0 -35
  143. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/code.js +0 -7
  144. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/output.js +0 -6
  145. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/code.js +0 -3
  146. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/output.js +0 -3
  147. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/code.js +0 -28
  148. package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/output.js +0 -34
  149. package/config/jest/babelPlugins/__tests__/__fixtures__/viteDistDir/client-build-manifest.json +0 -59
  150. package/config/jest/babelPlugins/__tests__/babel-plugin-redwood-cell.test.ts +0 -11
  151. package/config/jest/package.json +0 -3
@@ -0,0 +1,101 @@
1
+ import { parse } from "node:path";
2
+ const EXPECTED_EXPORTS_FROM_CELL = [
3
+ "beforeQuery",
4
+ "QUERY",
5
+ "data",
6
+ "isEmpty",
7
+ "afterQuery",
8
+ "Loading",
9
+ "Success",
10
+ "Failure",
11
+ "Empty"
12
+ ];
13
+ function isExpectedExport(name) {
14
+ return name !== void 0 && EXPECTED_EXPORTS_FROM_CELL.includes(name);
15
+ }
16
+ function babel_plugin_redwood_cell_default({
17
+ types
18
+ }) {
19
+ return {
20
+ name: "babel-plugin-redwood-cell",
21
+ visitor: {
22
+ ExportDefaultDeclaration(path, state) {
23
+ state.hasDefaultExport = true;
24
+ },
25
+ ExportNamedDeclaration(path, state) {
26
+ const declaration = path.node.declaration;
27
+ if (!declaration) {
28
+ return;
29
+ }
30
+ let name;
31
+ if (declaration.type === "VariableDeclaration") {
32
+ const id = declaration.declarations[0].id;
33
+ if (id.type === "Identifier") {
34
+ name = id.name;
35
+ }
36
+ }
37
+ if (declaration.type === "FunctionDeclaration") {
38
+ name = declaration?.id?.name;
39
+ }
40
+ if (isExpectedExport(name)) {
41
+ state.exportNames.push(name);
42
+ }
43
+ },
44
+ Program: {
45
+ enter(_path, state) {
46
+ state.exportNames = [];
47
+ state.hasDefaultExport = false;
48
+ },
49
+ exit(path, state) {
50
+ const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("data");
51
+ if (state.hasDefaultExport || !hasQueryOrDataExport) {
52
+ return;
53
+ }
54
+ const createCellHookName = state.exportNames.includes("data") ? "createServerCell" : "createCell";
55
+ const importFrom = state.exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
56
+ path.node.body.unshift(
57
+ types.importDeclaration(
58
+ [
59
+ types.importSpecifier(
60
+ types.identifier(createCellHookName),
61
+ types.identifier(createCellHookName)
62
+ )
63
+ ],
64
+ types.stringLiteral(importFrom)
65
+ )
66
+ );
67
+ const objectProperties = [
68
+ ...state.exportNames.map(
69
+ (name) => types.objectProperty(
70
+ types.identifier(name),
71
+ types.identifier(name),
72
+ false,
73
+ true
74
+ )
75
+ )
76
+ ];
77
+ if (state.file.opts.filename) {
78
+ objectProperties.push(
79
+ types.objectProperty(
80
+ types.identifier("displayName"),
81
+ types.stringLiteral(parse(state.file.opts.filename).name),
82
+ false,
83
+ true
84
+ )
85
+ );
86
+ }
87
+ path.node.body.push(
88
+ types.exportDefaultDeclaration(
89
+ types.callExpression(types.identifier(createCellHookName), [
90
+ types.objectExpression(objectProperties)
91
+ ])
92
+ )
93
+ );
94
+ }
95
+ }
96
+ }
97
+ };
98
+ }
99
+ export {
100
+ babel_plugin_redwood_cell_default as default
101
+ };
@@ -0,0 +1,8 @@
1
+ import jestRunner from 'jest-runner';
2
+ declare const TestRunner: (typeof jestRunner)['default'];
3
+ declare class SerialRunner extends TestRunner {
4
+ isSerial: boolean;
5
+ constructor(...attr: ConstructorParameters<typeof TestRunner>);
6
+ }
7
+ export = SerialRunner;
8
+ //# sourceMappingURL=jest-serial-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest-serial-runner.d.ts","sourceRoot":"","sources":["../../../src/config/jest/jest-serial-runner.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,MAAM,aAAa,CAAA;AAGpC,QAAA,MAAM,UAAU,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,SAAS,CAGb,CAAA;AAElC,cAAM,YAAa,SAAQ,UAAU;IAC5B,QAAQ,EAAE,OAAO,CAAA;gBAEZ,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC;CAI9D;AAMD,SAAS,YAAY,CAAA"}
@@ -0,0 +1,23 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+ import jestRunner from "jest-runner";
6
+ var require_jest_serial_runner = __commonJS({
7
+ "src/config/jest/jest-serial-runner.ts"(exports, module) {
8
+ const TestRunner = (
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore
11
+ jestRunner.default || jestRunner
12
+ );
13
+ class SerialRunner extends TestRunner {
14
+ isSerial;
15
+ constructor(...attr) {
16
+ super(...attr);
17
+ this.isSerial = true;
18
+ }
19
+ }
20
+ module.exports = SerialRunner;
21
+ }
22
+ });
23
+ export default require_jest_serial_runner();
@@ -0,0 +1,6 @@
1
+ import { TestEnvironment } from 'jest-environment-jsdom';
2
+ declare class RedwoodWebJestEnvironment extends TestEnvironment {
3
+ setup(): Promise<void>;
4
+ }
5
+ export default RedwoodWebJestEnvironment;
6
+ //# sourceMappingURL=RedwoodWebJestEnv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedwoodWebJestEnv.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/RedwoodWebJestEnv.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAIxD,cAAM,yBAA0B,SAAQ,eAAe;IAC/C,KAAK;CAaZ;AAED,eAAe,yBAAyB,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { TextEncoder, TextDecoder } from "node:util";
2
+ import { TestEnvironment } from "jest-environment-jsdom";
3
+ class RedwoodWebJestEnvironment extends TestEnvironment {
4
+ async setup() {
5
+ await super.setup();
6
+ if (typeof this.global.TextEncoder === "undefined") {
7
+ this.global.TextEncoder = TextEncoder;
8
+ this.global.TextDecoder = TextDecoder;
9
+ }
10
+ if (typeof this.global.crypto.subtle === "undefined") {
11
+ this.global.crypto.subtle = {};
12
+ }
13
+ }
14
+ }
15
+ var RedwoodWebJestEnv_default = RedwoodWebJestEnvironment;
16
+ export {
17
+ RedwoodWebJestEnv_default as default
18
+ };
@@ -0,0 +1,3 @@
1
+ import * as jestPreset from './jest-preset.js';
2
+ export = jestPreset;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAM9C,SAAS,UAAU,CAAA"}
@@ -0,0 +1,11 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+ import * as jestPreset from "./jest-preset.js";
6
+ var require_web = __commonJS({
7
+ "src/config/jest/web/index.ts"(exports, module) {
8
+ module.exports = jestPreset;
9
+ }
10
+ });
11
+ export default require_web();
@@ -0,0 +1,4 @@
1
+ import type { Config } from 'jest';
2
+ declare const config: Config;
3
+ export default config;
4
+ //# sourceMappingURL=jest-preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAOlC,QAAA,MAAM,MAAM,EAAE,MAgFb,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,87 @@
1
+ import path from "node:path";
2
+ import { getPaths } from "@cedarjs/project-config";
3
+ const rwjsPaths = getPaths();
4
+ const NODE_MODULES_PATH = path.join(rwjsPaths.base, "node_modules");
5
+ const config = {
6
+ // To make sure other config option which depends on rootDir always
7
+ // use correct path, for example, coverageDirectory
8
+ rootDir: rwjsPaths.base,
9
+ roots: [path.join(rwjsPaths.web.src)],
10
+ testEnvironment: path.join(__dirname, "./RedwoodWebJestEnv.js"),
11
+ displayName: {
12
+ color: "blueBright",
13
+ name: "web"
14
+ },
15
+ globals: {
16
+ __RWJS_TESTROOT_DIR: path.join(rwjsPaths.web.src),
17
+ // used in jest setup to load mocks
18
+ RWJS_ENV: {
19
+ RWJS_API_URL: "",
20
+ RWJS_API_GRAPHQL_URL: "/",
21
+ __REDWOOD__APP_TITLE: "Redwood App"
22
+ },
23
+ RWJS_DEBUG_ENV: {
24
+ RWJS_SRC_ROOT: rwjsPaths.web.src
25
+ }
26
+ },
27
+ collectCoverageFrom: [
28
+ "**/*.{js,jsx,ts,tsx}",
29
+ "!**/node_modules/**",
30
+ "!**/dist/**"
31
+ ],
32
+ coverageDirectory: path.join(rwjsPaths.base, "coverage"),
33
+ watchPlugins: [
34
+ "jest-watch-typeahead/filename",
35
+ "jest-watch-typeahead/testname"
36
+ ],
37
+ setupFilesAfterEnv: [path.resolve(__dirname, "./jest.setup.js")],
38
+ moduleNameMapper: {
39
+ /**
40
+ * Make sure modules that require different versions of these
41
+ * dependencies end up using the same one.
42
+ */
43
+ "^react$": path.join(NODE_MODULES_PATH, "react"),
44
+ "^react-dom$": path.join(NODE_MODULES_PATH, "react-dom"),
45
+ "^@apollo/client/react$": path.join(
46
+ NODE_MODULES_PATH,
47
+ "@apollo/client/react"
48
+ ),
49
+ // We replace imports to "@cedarjs/router" with our own "mock" implementation.
50
+ "^@cedarjs/router$": path.join(
51
+ NODE_MODULES_PATH,
52
+ "@cedarjs/testing/dist/cjs/web/MockRouter.js"
53
+ ),
54
+ "^@cedarjs/web$": path.join(NODE_MODULES_PATH, "@cedarjs/web/dist/cjs"),
55
+ // This allows us to mock `createAuthentication` which is used by auth
56
+ // clients, which in turn lets us mock `useAuth` in tests
57
+ "^@cedarjs/auth$": path.join(
58
+ NODE_MODULES_PATH,
59
+ "@cedarjs/testing/dist/cjs/web/mockAuth.js"
60
+ ),
61
+ // @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
62
+ // This is to prevent web stuff leaking into api, and vice versa
63
+ "^@cedarjs/testing$": path.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
64
+ "~__REDWOOD__USER_ROUTES_FOR_MOCK": rwjsPaths.web.routes,
65
+ "~__REDWOOD__USER_AUTH_FOR_MOCK": path.join(rwjsPaths.web.src, "auth"),
66
+ /**
67
+ * Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
68
+ */
69
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$": "@cedarjs/testing/dist/cjs/web/fileMock.js"
70
+ },
71
+ transform: {
72
+ "\\.[jt]sx?$": [
73
+ "babel-jest",
74
+ // When jest runs tests in parallel, it serializes the config before passing down options to babel
75
+ // that's why these must be serializable. Passing the reference to a config instead.
76
+ {
77
+ configFile: path.resolve(__dirname, "./webBabelConfig.js")
78
+ }
79
+ ]
80
+ },
81
+ resolver: path.resolve(__dirname, "./resolver.js"),
82
+ testPathIgnorePatterns: [".(stories|mock).[jt]sx?$"]
83
+ };
84
+ var jest_preset_default = config;
85
+ export {
86
+ jest_preset_default as default
87
+ };
@@ -0,0 +1,8 @@
1
+ import '@testing-library/jest-dom';
2
+ import 'whatwg-fetch';
3
+ import { mockCurrentUser as _mockCurrentUser } from '../../../web/mockRequests.js';
4
+ declare global {
5
+ var __RWJS_TESTROOT_DIR: string;
6
+ var mockCurrentUser: typeof _mockCurrentUser;
7
+ }
8
+ //# sourceMappingURL=jest.setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.setup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/jest.setup.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA;AAClC,OAAO,cAAc,CAAA;AAGrB,OAAO,EAML,eAAe,IAAI,gBAAgB,EACpC,MAAM,8BAA8B,CAAA;AAErC,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,mBAAmB,EAAE,MAAM,CAAA;IAE/B,IAAI,eAAe,EAAE,OAAO,gBAAgB,CAAA;CAC7C"}
@@ -0,0 +1,28 @@
1
+ import "@testing-library/jest-dom";
2
+ import "whatwg-fetch";
3
+ import { findCellMocks } from "../../../web/findCellMocks.js";
4
+ import {
5
+ startMSW,
6
+ setupRequestHandlers,
7
+ closeServer,
8
+ mockGraphQLMutation as _mockGraphQLMutation,
9
+ mockGraphQLQuery as _mockGraphQLQuery,
10
+ mockCurrentUser as _mockCurrentUser
11
+ } from "../../../web/mockRequests.js";
12
+ global.mockGraphQLQuery = _mockGraphQLQuery;
13
+ global.mockGraphQLMutation = _mockGraphQLMutation;
14
+ global.mockCurrentUser = _mockCurrentUser;
15
+ const cellMocks = findCellMocks(global.__RWJS_TESTROOT_DIR);
16
+ beforeAll(async () => {
17
+ for (const m of cellMocks) {
18
+ await import(m);
19
+ }
20
+ await startMSW("node");
21
+ setupRequestHandlers();
22
+ });
23
+ afterEach(() => {
24
+ setupRequestHandlers();
25
+ });
26
+ afterAll(() => {
27
+ closeServer();
28
+ });
@@ -0,0 +1,4 @@
1
+ import type { ResolverOptions } from 'jest-resolve';
2
+ declare function resolver(path: string, options: ResolverOptions): string;
3
+ export = resolver;
4
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/resolver.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,UAYvD;AAMD,SAAS,QAAQ,CAAA"}
@@ -0,0 +1,38 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+ var require_resolver = __commonJS({
6
+ "src/config/jest/web/resolver.ts"(exports, module) {
7
+ function resolver(path, options) {
8
+ return options.defaultResolver(path, {
9
+ ...options,
10
+ packageFilter: (pkg) => {
11
+ if (OVERRIDE_EXPORTS_LIST.has(pkg.name)) {
12
+ delete pkg["exports"];
13
+ delete pkg["module"];
14
+ }
15
+ return pkg;
16
+ }
17
+ });
18
+ }
19
+ const OVERRIDE_EXPORTS_LIST = /* @__PURE__ */ new Set([
20
+ "@firebase/analytics",
21
+ "@firebase/app",
22
+ "@firebase/app-check",
23
+ "@firebase/auth",
24
+ "@firebase/database",
25
+ "@firebase/firestore",
26
+ "@firebase/functions",
27
+ "@firebase/installations",
28
+ "@firebase/messaging",
29
+ "@firebase/performance",
30
+ "@firebase/remote-config",
31
+ "@firebase/storage",
32
+ "@firebase/util",
33
+ "firebase"
34
+ ]);
35
+ module.exports = resolver;
36
+ }
37
+ });
38
+ export default require_resolver();
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ overrides: import("@babel/core").TransformOptions[];
3
+ presets: ((string | undefined)[] | (string | object)[])[];
4
+ plugins: import("@babel/core").TransformOptions[];
5
+ extends: string | undefined;
6
+ babelrc: boolean;
7
+ ignore: string[];
8
+ };
9
+ export default _default;
10
+ //# sourceMappingURL=webBabelConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webBabelConfig.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/webBabelConfig.ts"],"names":[],"mappings":";;;;;;;;AAQA,wBASC"}
@@ -0,0 +1,18 @@
1
+ import { getWebSideDefaultBabelConfig } from "@cedarjs/babel-config";
2
+ import redwoodCellsPlugin from "../babelPlugins/babel-plugin-redwood-cell.js";
3
+ const defaultWebSideBabelConfig = getWebSideDefaultBabelConfig({
4
+ forJest: true
5
+ });
6
+ var webBabelConfig_default = {
7
+ ...defaultWebSideBabelConfig,
8
+ overrides: [
9
+ ...defaultWebSideBabelConfig.overrides,
10
+ {
11
+ test: /.+Cell.(js|tsx|jsx)$/,
12
+ plugins: [redwoodCellsPlugin]
13
+ }
14
+ ]
15
+ };
16
+ export {
17
+ webBabelConfig_default as default
18
+ };
@@ -1,6 +1,6 @@
1
1
  import type { mockGraphQLQuery as _mockGraphQLQuery, mockGraphQLMutation as _mockGraphQLMutation } from './mockRequests.js';
2
2
  declare global {
3
- const mockGraphQLQuery: typeof _mockGraphQLQuery;
4
- const mockGraphQLMutation: typeof _mockGraphQLMutation;
3
+ var mockGraphQLQuery: typeof _mockGraphQLQuery;
4
+ var mockGraphQLMutation: typeof _mockGraphQLMutation;
5
5
  }
6
6
  //# sourceMappingURL=global.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/web/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,IAAI,iBAAiB,EACrC,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,mBAAmB,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,CAAA;IAChD,MAAM,mBAAmB,EAAE,OAAO,oBAAoB,CAAA;CAGvD"}
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/web/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,IAAI,iBAAiB,EACrC,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,mBAAmB,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,OAAO,iBAAiB,CAAA;IAE9C,IAAI,mBAAmB,EAAE,OAAO,oBAAoB,CAAA;CAGrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/testing",
3
- "version": "0.6.1-next.0+2f33ffc44",
3
+ "version": "0.6.1-next.51+7c9a976df",
4
4
  "description": "Tools, wrappers and configuration for testing a CedarJS project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,15 +22,24 @@
22
22
  "./config/jest/web/jest-preset": {
23
23
  "default": "./config/jest/web/jest-preset.js"
24
24
  },
25
- "./dist/cjs/api/scenario": {
25
+ "./dist/cjs/api/scenario.js": {
26
26
  "default": "./dist/cjs/api/scenario.js"
27
27
  },
28
+ "./dist/cjs/api/directUrlHelpers.js": {
29
+ "default": "./dist/cjs/api/directUrlHelpers.js"
30
+ },
28
31
  "./dist/cjs/web/findCellMocks": {
29
32
  "default": "./dist/cjs/web/findCellMocks.js"
30
33
  },
31
34
  "./dist/cjs/web/mockRequests": {
32
35
  "default": "./dist/cjs/web/mockRequests.js"
33
36
  },
37
+ "./dist/cjs/web/mockRequests.js": {
38
+ "default": "./dist/cjs/web/mockRequests.js"
39
+ },
40
+ "./dist/cjs/web/fileMock.js": {
41
+ "default": "./dist/cjs/web/fileMock.js"
42
+ },
34
43
  "./auth": {
35
44
  "import": {
36
45
  "types": "./dist/web/mockAuth.d.ts",
@@ -92,13 +101,13 @@
92
101
  "test:watch": "vitest watch"
93
102
  },
94
103
  "dependencies": {
95
- "@cedarjs/auth": "0.6.1-next.0+2f33ffc44",
96
- "@cedarjs/babel-config": "0.6.1-next.0+2f33ffc44",
97
- "@cedarjs/context": "0.6.1-next.0+2f33ffc44",
98
- "@cedarjs/graphql-server": "0.6.1-next.0+2f33ffc44",
99
- "@cedarjs/project-config": "0.6.1-next.0+2f33ffc44",
100
- "@cedarjs/router": "0.6.1-next.0+2f33ffc44",
101
- "@cedarjs/web": "0.6.1-next.0+2f33ffc44",
104
+ "@cedarjs/auth": "0.6.1-next.51+7c9a976df",
105
+ "@cedarjs/babel-config": "0.6.1-next.51+7c9a976df",
106
+ "@cedarjs/context": "0.6.1-next.51+7c9a976df",
107
+ "@cedarjs/graphql-server": "0.6.1-next.51+7c9a976df",
108
+ "@cedarjs/project-config": "0.6.1-next.51+7c9a976df",
109
+ "@cedarjs/router": "0.6.1-next.51+7c9a976df",
110
+ "@cedarjs/web": "0.6.1-next.51+7c9a976df",
102
111
  "@testing-library/jest-dom": "6.5.0",
103
112
  "@testing-library/react": "14.3.1",
104
113
  "@testing-library/user-event": "14.5.2",
@@ -116,7 +125,7 @@
116
125
  "whatwg-fetch": "3.6.20"
117
126
  },
118
127
  "devDependencies": {
119
- "@cedarjs/framework-tools": "0.6.1-next.1",
128
+ "@cedarjs/framework-tools": "0.6.1-next.51",
120
129
  "concurrently": "8.2.2",
121
130
  "jsdom": "24.1.3",
122
131
  "publint": "0.3.12",
@@ -127,5 +136,5 @@
127
136
  "publishConfig": {
128
137
  "access": "public"
129
138
  },
130
- "gitHead": "2f33ffc44a616d71e3954228ea2f09e6d1b976f2"
139
+ "gitHead": "7c9a976df61eea55cbabae015395da84f807222f"
131
140
  }
@@ -1,28 +0,0 @@
1
- export const QUERY = gql`
2
- query {
3
- posts {
4
- id
5
- title
6
- body
7
- }
8
- }
9
- `
10
-
11
- // export const beforeQuery = () => ({})
12
- export const afterQuery = () => ({})
13
-
14
- export function Loading() {
15
- return 'Loading'
16
- }
17
-
18
- // export function Empty() {
19
- // return 'Empty'
20
- // }
21
-
22
- export function Failure({ error }) {
23
- return error.message
24
- }
25
-
26
- export const Success = ({ posts }) => {
27
- return JSON.stringify(posts, null, 2)
28
- }
@@ -1,35 +0,0 @@
1
- import { createCell } from '@cedarjs/web'
2
- export const QUERY = gql`
3
- query {
4
- posts {
5
- id
6
- title
7
- body
8
- }
9
- }
10
- `
11
-
12
- // export const beforeQuery = () => ({})
13
- export const afterQuery = () => ({})
14
- export function Loading() {
15
- return 'Loading'
16
- }
17
-
18
- // export function Empty() {
19
- // return 'Empty'
20
- // }
21
-
22
- export function Failure({ error }) {
23
- return error.message
24
- }
25
- export const Success = ({ posts }) => {
26
- return JSON.stringify(posts, null, 2)
27
- }
28
- export default createCell({
29
- QUERY,
30
- afterQuery,
31
- Loading,
32
- Failure,
33
- Success,
34
- displayName: 'code',
35
- })
@@ -1,7 +0,0 @@
1
- export const Success = () => {
2
- return 'string'
3
- }
4
-
5
- export default () => {
6
- return 'string'
7
- }
@@ -1,6 +0,0 @@
1
- export const Success = () => {
2
- return 'string'
3
- }
4
- export default () => {
5
- return 'string'
6
- }
@@ -1,3 +0,0 @@
1
- export default () => {
2
- return 'string'
3
- }
@@ -1,3 +0,0 @@
1
- export default () => {
2
- return 'string'
3
- }
@@ -1,28 +0,0 @@
1
- export const QUERY = gql`
2
- query {
3
- posts {
4
- id
5
- title
6
- body
7
- }
8
- }
9
- `
10
-
11
- export const beforeQuery = () => ({})
12
- export const afterQuery = () => ({})
13
-
14
- export function Loading() {
15
- return 'Loading'
16
- }
17
-
18
- export function Empty() {
19
- return 'Empty'
20
- }
21
-
22
- export function Failure({ error }) {
23
- return error.message
24
- }
25
-
26
- export const Success = ({ posts }) => {
27
- return JSON.stringify(posts, null, 2)
28
- }
@@ -1,34 +0,0 @@
1
- import { createCell } from '@cedarjs/web'
2
- export const QUERY = gql`
3
- query {
4
- posts {
5
- id
6
- title
7
- body
8
- }
9
- }
10
- `
11
- export const beforeQuery = () => ({})
12
- export const afterQuery = () => ({})
13
- export function Loading() {
14
- return 'Loading'
15
- }
16
- export function Empty() {
17
- return 'Empty'
18
- }
19
- export function Failure({ error }) {
20
- return error.message
21
- }
22
- export const Success = ({ posts }) => {
23
- return JSON.stringify(posts, null, 2)
24
- }
25
- export default createCell({
26
- QUERY,
27
- beforeQuery,
28
- afterQuery,
29
- Loading,
30
- Empty,
31
- Failure,
32
- Success,
33
- displayName: 'code',
34
- })