@cedarjs/testing 0.6.1-next.0 → 0.7.0

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
@@ -1,142 +1,121 @@
1
- const { parse } = require('path')
2
-
3
- // This wraps a file that has a suffix of `Cell` in Redwood's `createCell` higher
4
- // order component. The HOC deals with the lifecycle methods during a GraphQL query.
5
- //
6
- // ```js
7
- // import { createCell } from '@cedarjs/web'
8
- // <YOUR CODE>
9
- // export default createCell({ QUERY, Loading, Success, Failure, isEmpty, Empty, beforeQuery, afterQuery, displayName })
10
- // ```
11
- //
12
- // To debug the output of the plugin, you can use the following:
13
- // ```
14
- // import generate from '@babel/generator'
15
- // // ...
16
- // console.log(generate(path.node).code)
17
- // ```
18
-
19
- // A cell can export the declarations below.
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 babel_plugin_redwood_cell_exports = {};
20
+ __export(babel_plugin_redwood_cell_exports, {
21
+ default: () => babel_plugin_redwood_cell_default
22
+ });
23
+ module.exports = __toCommonJS(babel_plugin_redwood_cell_exports);
24
+ var import_node_path = require("node:path");
20
25
  const EXPECTED_EXPORTS_FROM_CELL = [
21
- 'beforeQuery',
22
- 'QUERY',
23
- 'data',
24
- 'isEmpty',
25
- 'afterQuery',
26
- 'Loading',
27
- 'Success',
28
- 'Failure',
29
- 'Empty',
30
- ]
31
-
32
- module.exports = function ({ types: t }) {
33
- // This array will collect exports from the Cell file during
34
- // ExportNamedDeclaration
35
- // - collected exports will then be passed to `createCell`
36
- // - The array is reset every time we `enter` a new Program
37
- let exportNames = []
38
- let hasDefaultExport = false
39
-
26
+ "beforeQuery",
27
+ "QUERY",
28
+ "data",
29
+ "isEmpty",
30
+ "afterQuery",
31
+ "Loading",
32
+ "Success",
33
+ "Failure",
34
+ "Empty"
35
+ ];
36
+ function isExpectedExport(name) {
37
+ return name !== void 0 && EXPECTED_EXPORTS_FROM_CELL.includes(name);
38
+ }
39
+ function babel_plugin_redwood_cell_default({
40
+ types
41
+ }) {
40
42
  return {
41
- name: 'babel-plugin-redwood-cell',
43
+ name: "babel-plugin-redwood-cell",
42
44
  visitor: {
43
- ExportDefaultDeclaration() {
44
- hasDefaultExport = true
45
+ ExportDefaultDeclaration(path, state) {
46
+ state.hasDefaultExport = true;
45
47
  },
46
- ExportNamedDeclaration(path) {
47
- const declaration = path.node.declaration
48
-
48
+ ExportNamedDeclaration(path, state) {
49
+ const declaration = path.node.declaration;
49
50
  if (!declaration) {
50
- return
51
+ return;
51
52
  }
52
-
53
- let name
54
- if (declaration.type === 'VariableDeclaration') {
55
- const id = declaration.declarations[0].id
56
- name = id.name
53
+ let name;
54
+ if (declaration.type === "VariableDeclaration") {
55
+ const id = declaration.declarations[0].id;
56
+ if (id.type === "Identifier") {
57
+ name = id.name;
58
+ }
57
59
  }
58
- if (declaration.type === 'FunctionDeclaration') {
59
- name = declaration?.id?.name
60
+ if (declaration.type === "FunctionDeclaration") {
61
+ name = declaration?.id?.name;
60
62
  }
61
-
62
- if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
63
- exportNames.push(name)
63
+ if (isExpectedExport(name)) {
64
+ state.exportNames.push(name);
64
65
  }
65
66
  },
66
67
  Program: {
67
- enter() {
68
- // Reset variables as they're still in scope from the previous file
69
- // babel transformed in the same process
70
- exportNames = []
71
- hasDefaultExport = false
68
+ enter(_path, state) {
69
+ state.exportNames = [];
70
+ state.hasDefaultExport = false;
72
71
  },
73
- exit(path) {
74
- const hasQueryOrDataExport =
75
- exportNames.includes('QUERY') || exportNames.includes('data')
76
-
77
- // If the file already has a default export then
78
- // 1. It's likely not a cell, or it's a cell that's already been
79
- // wrapped in `createCell`
80
- // 2. If we added another default export we'd be breaking JS module
81
- // rules. There can only be one default export.
82
- // If there's no `QUERY` or `data` export it's not a valid cell
83
- if (hasDefaultExport || !hasQueryOrDataExport) {
84
- return
72
+ exit(path, state) {
73
+ const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("data");
74
+ if (state.hasDefaultExport || !hasQueryOrDataExport) {
75
+ return;
85
76
  }
86
-
87
- // TODO (RSC): When we want to support `data = async () => {}` in
88
- // client cells as well, we'll need a different heuristic here
89
- // If we want to support `QUERY` (gql) cells on the server we'll
90
- // also need a different heuristic
91
- const createCellHookName = exportNames.includes('data')
92
- ? 'createServerCell'
93
- : 'createCell'
94
- const importFrom = exportNames.includes('data')
95
- ? '@cedarjs/web/dist/components/cell/createServerCell'
96
- : '@cedarjs/web'
97
-
98
- // Insert at the top of the file:
99
- // + import { createCell } from '@cedarjs/web'
77
+ const createCellHookName = state.exportNames.includes("data") ? "createServerCell" : "createCell";
78
+ const importFrom = state.exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
100
79
  path.node.body.unshift(
101
- t.importDeclaration(
80
+ types.importDeclaration(
102
81
  [
103
- t.importSpecifier(
104
- t.identifier(createCellHookName),
105
- t.identifier(createCellHookName),
106
- ),
82
+ types.importSpecifier(
83
+ types.identifier(createCellHookName),
84
+ types.identifier(createCellHookName)
85
+ )
107
86
  ],
108
- t.stringLiteral(importFrom),
109
- ),
110
- )
111
-
112
- // Insert at the bottom of the file:
113
- // + export default createCell({ QUERY?, Loading?, Success?, Failure?, Empty?, beforeQuery?, isEmpty, afterQuery?, displayName? })
87
+ types.stringLiteral(importFrom)
88
+ )
89
+ );
90
+ const objectProperties = [
91
+ ...state.exportNames.map(
92
+ (name) => types.objectProperty(
93
+ types.identifier(name),
94
+ types.identifier(name),
95
+ false,
96
+ true
97
+ )
98
+ )
99
+ ];
100
+ if (state.file.opts.filename) {
101
+ objectProperties.push(
102
+ types.objectProperty(
103
+ types.identifier("displayName"),
104
+ types.stringLiteral((0, import_node_path.parse)(state.file.opts.filename).name),
105
+ false,
106
+ true
107
+ )
108
+ );
109
+ }
114
110
  path.node.body.push(
115
- t.exportDefaultDeclaration(
116
- t.callExpression(t.identifier(createCellHookName), [
117
- t.objectExpression([
118
- ...exportNames.map((name) =>
119
- t.objectProperty(
120
- t.identifier(name),
121
- t.identifier(name),
122
- false,
123
- true,
124
- ),
125
- ),
126
- // Add the `displayName` property so we can name the Cell
127
- // after the filename.
128
- t.objectProperty(
129
- t.identifier('displayName'),
130
- t.stringLiteral(parse(this.file.opts.filename).name),
131
- false,
132
- true,
133
- ),
134
- ]),
135
- ]),
136
- ),
137
- )
138
- },
139
- },
140
- },
141
- }
111
+ types.exportDefaultDeclaration(
112
+ types.callExpression(types.identifier(createCellHookName), [
113
+ types.objectExpression(objectProperties)
114
+ ])
115
+ )
116
+ );
117
+ }
118
+ }
119
+ }
120
+ };
142
121
  }
@@ -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"}
@@ -1,13 +1,37 @@
1
- // Originally from https://github.com/gabrieli/jest-serial-runner/blob/master/index.js
2
- // with fixed module export
3
-
4
- const TestRunner = require('jest-runner').default
5
-
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_jest_runner = __toESM(require("jest-runner"), 1);
25
+ const TestRunner = (
26
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
+ // @ts-ignore
28
+ import_jest_runner.default.default || import_jest_runner.default
29
+ );
6
30
  class SerialRunner extends TestRunner {
31
+ isSerial;
7
32
  constructor(...attr) {
8
- super(...attr)
9
- this.isSerial = true
33
+ super(...attr);
34
+ this.isSerial = true;
10
35
  }
11
36
  }
12
-
13
- module.exports = SerialRunner
37
+ module.exports = SerialRunner;
@@ -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"}
@@ -1,17 +1,38 @@
1
- const { TestEnvironment } = require('jest-environment-jsdom')
2
-
3
- // Due to issue: https://github.com/jsdom/jsdom/issues/2524
4
- // Fix from: https://github.com/jsdom/jsdom/issues/2524#issuecomment-736672511
5
- module.exports = class RedwoodWebJestEnv extends TestEnvironment {
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 RedwoodWebJestEnv_exports = {};
20
+ __export(RedwoodWebJestEnv_exports, {
21
+ default: () => RedwoodWebJestEnv_default
22
+ });
23
+ module.exports = __toCommonJS(RedwoodWebJestEnv_exports);
24
+ var import_node_util = require("node:util");
25
+ var import_jest_environment_jsdom = require("jest-environment-jsdom");
26
+ class RedwoodWebJestEnvironment extends import_jest_environment_jsdom.TestEnvironment {
6
27
  async setup() {
7
- await super.setup()
8
- if (typeof this.global.TextEncoder === 'undefined') {
9
- const { TextEncoder, TextDecoder } = require('util')
10
- this.global.TextEncoder = TextEncoder
11
- this.global.TextDecoder = TextDecoder
28
+ await super.setup();
29
+ if (typeof this.global.TextEncoder === "undefined") {
30
+ this.global.TextEncoder = import_node_util.TextEncoder;
31
+ this.global.TextDecoder = import_node_util.TextDecoder;
12
32
  }
13
- if (typeof this.global.crypto.subtle === 'undefined') {
14
- this.global.crypto.subtle = {} // To make tests work with auth that use WebCrypto like auth0
33
+ if (typeof this.global.crypto.subtle === "undefined") {
34
+ this.global.crypto.subtle = {};
15
35
  }
16
36
  }
17
37
  }
38
+ var RedwoodWebJestEnv_default = RedwoodWebJestEnvironment;
@@ -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"}
@@ -1,2 +1,25 @@
1
- // This is for backwards compatibility
2
- module.exports = require('./jest-preset')
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var jestPreset = __toESM(require("./jest-preset.js"), 1);
25
+ module.exports = jestPreset;
@@ -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"}
@@ -1,89 +1,117 @@
1
- const path = require('path')
2
-
3
- const { getPaths } = require('@cedarjs/project-config')
4
-
5
- const rwjsPaths = getPaths()
6
- const NODE_MODULES_PATH = path.join(rwjsPaths.base, 'node_modules')
7
-
8
- /** @type {import('jest').Config} */
9
- module.exports = {
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 jest_preset_exports = {};
30
+ __export(jest_preset_exports, {
31
+ default: () => jest_preset_default
32
+ });
33
+ module.exports = __toCommonJS(jest_preset_exports);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
+ var import_project_config = require("@cedarjs/project-config");
36
+ const rwjsPaths = (0, import_project_config.getPaths)();
37
+ const NODE_MODULES_PATH = import_node_path.default.join(rwjsPaths.base, "node_modules");
38
+ const config = {
10
39
  // To make sure other config option which depends on rootDir always
11
40
  // use correct path, for example, coverageDirectory
12
41
  rootDir: rwjsPaths.base,
13
- roots: [path.join(rwjsPaths.web.src)],
14
- testEnvironment: path.join(__dirname, './RedwoodWebJestEnv.js'),
42
+ roots: [import_node_path.default.join(rwjsPaths.web.src)],
43
+ testEnvironment: import_node_path.default.join(__dirname, "./RedwoodWebJestEnv.js"),
15
44
  displayName: {
16
- color: 'blueBright',
17
- name: 'web',
45
+ color: "blueBright",
46
+ name: "web"
18
47
  },
19
48
  globals: {
20
- __RWJS_TESTROOT_DIR: path.join(rwjsPaths.web.src), // used in jest setup to load mocks
49
+ __RWJS_TESTROOT_DIR: import_node_path.default.join(rwjsPaths.web.src),
50
+ // used in jest setup to load mocks
21
51
  RWJS_ENV: {
22
- RWJS_API_URL: '',
23
- RWJS_API_GRAPHQL_URL: '/',
24
- __REDWOOD__APP_TITLE: 'Redwood App',
52
+ RWJS_API_URL: "",
53
+ RWJS_API_GRAPHQL_URL: "/",
54
+ __REDWOOD__APP_TITLE: "Redwood App"
25
55
  },
26
56
  RWJS_DEBUG_ENV: {
27
- RWJS_SRC_ROOT: rwjsPaths.web.src,
28
- },
57
+ RWJS_SRC_ROOT: rwjsPaths.web.src
58
+ }
29
59
  },
30
60
  collectCoverageFrom: [
31
- '**/*.{js,jsx,ts,tsx}',
32
- '!**/node_modules/**',
33
- '!**/dist/**',
61
+ "**/*.{js,jsx,ts,tsx}",
62
+ "!**/node_modules/**",
63
+ "!**/dist/**"
34
64
  ],
35
- coverageDirectory: path.join(rwjsPaths.base, 'coverage'),
65
+ coverageDirectory: import_node_path.default.join(rwjsPaths.base, "coverage"),
36
66
  watchPlugins: [
37
- 'jest-watch-typeahead/filename',
38
- 'jest-watch-typeahead/testname',
67
+ "jest-watch-typeahead/filename",
68
+ "jest-watch-typeahead/testname"
39
69
  ],
40
- setupFilesAfterEnv: [path.resolve(__dirname, './jest.setup.js')],
70
+ setupFilesAfterEnv: [import_node_path.default.resolve(__dirname, "./jest.setup.js")],
41
71
  moduleNameMapper: {
42
72
  /**
43
73
  * Make sure modules that require different versions of these
44
74
  * dependencies end up using the same one.
45
75
  */
46
- '^react$': path.join(NODE_MODULES_PATH, 'react'),
47
- '^react-dom$': path.join(NODE_MODULES_PATH, 'react-dom'),
48
- '^@apollo/client/react$': path.join(
76
+ "^react$": import_node_path.default.join(NODE_MODULES_PATH, "react"),
77
+ "^react-dom$": import_node_path.default.join(NODE_MODULES_PATH, "react-dom"),
78
+ "^@apollo/client/react$": import_node_path.default.join(
49
79
  NODE_MODULES_PATH,
50
- '@apollo/client/react',
80
+ "@apollo/client/react"
51
81
  ),
52
82
  // We replace imports to "@cedarjs/router" with our own "mock" implementation.
53
- '^@cedarjs/router$': path.join(
83
+ "^@cedarjs/router$": import_node_path.default.join(
54
84
  NODE_MODULES_PATH,
55
- '@cedarjs/testing/dist/cjs/web/MockRouter.js',
85
+ "@cedarjs/testing/dist/cjs/web/MockRouter.js"
56
86
  ),
57
- '^@cedarjs/web$': path.join(NODE_MODULES_PATH, '@cedarjs/web/dist/cjs'),
58
-
87
+ "^@cedarjs/web$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/web/dist/cjs"),
59
88
  // This allows us to mock `createAuthentication` which is used by auth
60
89
  // clients, which in turn lets us mock `useAuth` in tests
61
- '^@cedarjs/auth$': path.join(
90
+ "^@cedarjs/auth$": import_node_path.default.join(
62
91
  NODE_MODULES_PATH,
63
- '@cedarjs/testing/dist/cjs/web/mockAuth.js',
92
+ "@cedarjs/testing/dist/cjs/web/mockAuth.js"
64
93
  ),
65
-
66
94
  // @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
67
95
  // This is to prevent web stuff leaking into api, and vice versa
68
- '^@cedarjs/testing$': path.join(NODE_MODULES_PATH, '@cedarjs/testing/web'),
69
- '~__REDWOOD__USER_ROUTES_FOR_MOCK': rwjsPaths.web.routes,
70
- '~__REDWOOD__USER_AUTH_FOR_MOCK': path.join(rwjsPaths.web.src, 'auth'),
96
+ "^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
97
+ "~__REDWOOD__USER_ROUTES_FOR_MOCK": rwjsPaths.web.routes,
98
+ "~__REDWOOD__USER_AUTH_FOR_MOCK": import_node_path.default.join(rwjsPaths.web.src, "auth"),
71
99
  /**
72
100
  * Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
73
101
  */
74
- '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$':
75
- '@cedarjs/testing/dist/web/fileMock.js',
102
+ "\\.(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"
76
103
  },
77
104
  transform: {
78
- '\\.[jt]sx?$': [
79
- 'babel-jest',
105
+ "\\.[jt]sx?$": [
106
+ "babel-jest",
80
107
  // When jest runs tests in parallel, it serializes the config before passing down options to babel
81
108
  // that's why these must be serializable. Passing the reference to a config instead.
82
109
  {
83
- configFile: path.resolve(__dirname, './webBabelConfig.js'),
84
- },
85
- ],
110
+ configFile: import_node_path.default.resolve(__dirname, "./webBabelConfig.js")
111
+ }
112
+ ]
86
113
  },
87
- resolver: path.resolve(__dirname, './resolver.js'),
88
- testPathIgnorePatterns: ['.(stories|mock).[jt]sx?$'],
89
- }
114
+ resolver: import_node_path.default.resolve(__dirname, "./resolver.js"),
115
+ testPathIgnorePatterns: [".(stories|mock).[jt]sx?$"]
116
+ };
117
+ var jest_preset_default = config;
@@ -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"}