@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.
- package/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/config/jest/api/RedwoodApiJestEnv.js +33 -16
- package/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/config/jest/api/apiBabelConfig.js +33 -17
- package/config/jest/api/globalSetup.d.ts +3 -0
- package/config/jest/api/globalSetup.d.ts.map +1 -0
- package/config/jest/api/globalSetup.js +59 -44
- package/config/jest/api/index.d.ts +3 -0
- package/config/jest/api/index.d.ts.map +1 -0
- package/config/jest/api/index.js +25 -2
- package/config/jest/api/jest-preset.d.ts +4 -0
- package/config/jest/api/jest-preset.d.ts.map +1 -0
- package/config/jest/api/jest-preset.js +69 -39
- package/config/jest/api/jest.setup.d.ts +2 -0
- package/config/jest/api/jest.setup.d.ts.map +1 -0
- package/config/jest/api/jest.setup.js +189 -248
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +103 -124
- package/config/jest/jest-serial-runner.d.ts +8 -0
- package/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/config/jest/jest-serial-runner.js +33 -9
- package/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/config/jest/web/RedwoodWebJestEnv.js +33 -12
- package/config/jest/web/index.d.ts +3 -0
- package/config/jest/web/index.d.ts.map +1 -0
- package/config/jest/web/index.js +25 -2
- package/config/jest/web/jest-preset.d.ts +4 -0
- package/config/jest/web/jest-preset.d.ts.map +1 -0
- package/config/jest/web/jest-preset.js +78 -50
- package/config/jest/web/jest.setup.d.ts +8 -0
- package/config/jest/web/jest.setup.d.ts.map +1 -0
- package/config/jest/web/jest.setup.js +17 -36
- package/config/jest/web/resolver.d.ts +4 -0
- package/config/jest/web/resolver.d.ts.map +1 -0
- package/config/jest/web/resolver.js +24 -31
- package/config/jest/web/webBabelConfig.d.ts +10 -0
- package/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/config/jest/web/webBabelConfig.js +43 -13
- package/config/package.json +1 -0
- package/dist/api/directUrlHelpers.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/cjs/api/directUrlHelpers.d.ts.map +1 -1
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.d.ts.map +1 -1
- package/dist/cjs/api/index.js +3 -1
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +48 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.js +34 -0
- package/dist/cjs/config/jest/api/globalSetup.d.ts +3 -0
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/globalSetup.js +61 -0
- package/dist/cjs/config/jest/api/index.d.ts +3 -0
- package/dist/cjs/config/jest/api/index.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/index.js +25 -0
- package/dist/cjs/config/jest/api/jest-preset.d.ts +4 -0
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/jest-preset.js +97 -0
- package/dist/cjs/config/jest/api/jest.setup.d.ts +2 -0
- package/dist/cjs/config/jest/api/jest.setup.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/jest.setup.js +267 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +121 -0
- package/dist/cjs/config/jest/jest-serial-runner.d.ts +8 -0
- package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/dist/cjs/config/jest/jest-serial-runner.js +37 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +38 -0
- package/dist/cjs/config/jest/web/index.d.ts +3 -0
- package/dist/cjs/config/jest/web/index.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/index.js +25 -0
- package/dist/cjs/config/jest/web/jest-preset.d.ts +4 -0
- package/dist/cjs/config/jest/web/jest-preset.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/jest-preset.js +117 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts +8 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/jest.setup.js +22 -0
- package/dist/cjs/config/jest/web/resolver.d.ts +4 -0
- package/dist/cjs/config/jest/web/resolver.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/resolver.js +30 -0
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts +10 -0
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/webBabelConfig.js +48 -0
- package/dist/cjs/web/global.d.ts +2 -2
- package/dist/cjs/web/global.d.ts.map +1 -1
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/dist/config/jest/api/RedwoodApiJestEnv.js +28 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/dist/config/jest/api/apiBabelConfig.js +18 -0
- package/dist/config/jest/api/globalSetup.d.ts +3 -0
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -0
- package/dist/config/jest/api/globalSetup.js +34 -0
- package/dist/config/jest/api/index.d.ts +3 -0
- package/dist/config/jest/api/index.d.ts.map +1 -0
- package/dist/config/jest/api/index.js +11 -0
- package/dist/config/jest/api/jest-preset.d.ts +4 -0
- package/dist/config/jest/api/jest-preset.d.ts.map +1 -0
- package/dist/config/jest/api/jest-preset.js +67 -0
- package/dist/config/jest/api/jest.setup.d.ts +2 -0
- package/dist/config/jest/api/jest.setup.d.ts.map +1 -0
- package/dist/config/jest/api/jest.setup.js +244 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +101 -0
- package/dist/config/jest/jest-serial-runner.d.ts +8 -0
- package/dist/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/dist/config/jest/jest-serial-runner.js +23 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.js +18 -0
- package/dist/config/jest/web/index.d.ts +3 -0
- package/dist/config/jest/web/index.d.ts.map +1 -0
- package/dist/config/jest/web/index.js +11 -0
- package/dist/config/jest/web/jest-preset.d.ts +4 -0
- package/dist/config/jest/web/jest-preset.d.ts.map +1 -0
- package/dist/config/jest/web/jest-preset.js +87 -0
- package/dist/config/jest/web/jest.setup.d.ts +8 -0
- package/dist/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/config/jest/web/jest.setup.js +28 -0
- package/dist/config/jest/web/resolver.d.ts +4 -0
- package/dist/config/jest/web/resolver.d.ts.map +1 -0
- package/dist/config/jest/web/resolver.js +38 -0
- package/dist/config/jest/web/webBabelConfig.d.ts +10 -0
- package/dist/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/dist/config/jest/web/webBabelConfig.js +18 -0
- package/dist/web/global.d.ts +2 -2
- package/dist/web/global.d.ts.map +1 -1
- package/package.json +20 -11
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/code.js +0 -28
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/output.js +0 -35
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/code.js +0 -7
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/output.js +0 -6
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/code.js +0 -3
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/output.js +0 -3
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/code.js +0 -28
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/output.js +0 -34
- package/config/jest/babelPlugins/__tests__/__fixtures__/viteDistDir/client-build-manifest.json +0 -59
- package/config/jest/babelPlugins/__tests__/babel-plugin-redwood-cell.test.ts +0 -11
- package/config/jest/package.json +0 -3
|
@@ -1,142 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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:
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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 ===
|
|
59
|
-
name = declaration?.id?.name
|
|
60
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
61
|
+
name = declaration?.id?.name;
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
exportNames.push(name)
|
|
63
|
+
if (isExpectedExport(name)) {
|
|
64
|
+
state.exportNames.push(name);
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
Program: {
|
|
67
|
-
enter() {
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
80
|
+
types.importDeclaration(
|
|
102
81
|
[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
)
|
|
82
|
+
types.importSpecifier(
|
|
83
|
+
types.identifier(createCellHookName),
|
|
84
|
+
types.identifier(createCellHookName)
|
|
85
|
+
)
|
|
107
86
|
],
|
|
108
|
-
|
|
109
|
-
)
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 @@
|
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 ===
|
|
9
|
-
|
|
10
|
-
this.global.
|
|
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 ===
|
|
14
|
-
this.global.crypto.subtle = {}
|
|
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 @@
|
|
|
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"}
|
package/config/jest/web/index.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 @@
|
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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: [
|
|
14
|
-
testEnvironment:
|
|
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:
|
|
17
|
-
name:
|
|
45
|
+
color: "blueBright",
|
|
46
|
+
name: "web"
|
|
18
47
|
},
|
|
19
48
|
globals: {
|
|
20
|
-
__RWJS_TESTROOT_DIR:
|
|
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:
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
"**/*.{js,jsx,ts,tsx}",
|
|
62
|
+
"!**/node_modules/**",
|
|
63
|
+
"!**/dist/**"
|
|
34
64
|
],
|
|
35
|
-
coverageDirectory:
|
|
65
|
+
coverageDirectory: import_node_path.default.join(rwjsPaths.base, "coverage"),
|
|
36
66
|
watchPlugins: [
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
"jest-watch-typeahead/filename",
|
|
68
|
+
"jest-watch-typeahead/testname"
|
|
39
69
|
],
|
|
40
|
-
setupFilesAfterEnv: [
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
80
|
+
"@apollo/client/react"
|
|
51
81
|
),
|
|
52
82
|
// We replace imports to "@cedarjs/router" with our own "mock" implementation.
|
|
53
|
-
|
|
83
|
+
"^@cedarjs/router$": import_node_path.default.join(
|
|
54
84
|
NODE_MODULES_PATH,
|
|
55
|
-
|
|
85
|
+
"@cedarjs/testing/dist/cjs/web/MockRouter.js"
|
|
56
86
|
),
|
|
57
|
-
|
|
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
|
-
|
|
90
|
+
"^@cedarjs/auth$": import_node_path.default.join(
|
|
62
91
|
NODE_MODULES_PATH,
|
|
63
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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:
|
|
84
|
-
}
|
|
85
|
-
]
|
|
110
|
+
configFile: import_node_path.default.resolve(__dirname, "./webBabelConfig.js")
|
|
111
|
+
}
|
|
112
|
+
]
|
|
86
113
|
},
|
|
87
|
-
resolver:
|
|
88
|
-
testPathIgnorePatterns: [
|
|
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"}
|