Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
107 lines (103 loc) · 3.1 KB
/
Copy pathjest.config.js
File metadata and controls
107 lines (103 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */
const config = {
preset: "ts-jest",
testEnvironment: "node",
globals: {
"ts-jest": {
tsconfig: {
target: "ES2019",
module: "commonjs",
resolveJsonModule: true,
esModuleInterop: true,
jsx: "react",
baseUrl: __dirname,
paths: {
"@theme/*": ["packages/docusaurus-theme-openapi-docs/src/theme/*"],
},
},
},
},
roots: [
"<rootDir>/packages/docusaurus-plugin-openapi-docs/src",
"<rootDir>/packages/docusaurus-theme-openapi-docs/src",
],
moduleNameMapper: {
"^@theme/(.*)$":
"<rootDir>/packages/docusaurus-theme-openapi-docs/src/theme/$1",
"^chalk$": "<rootDir>/__mocks__/chalk.js",
"^@apidevtools/json-schema-ref-parser$":
"<rootDir>/__mocks__/@apidevtools/json-schema-ref-parser.js",
"^@redocly/openapi-core$": "<rootDir>/__mocks__/@redocly/openapi-core.js",
"^neotraverse/legacy$":
"<rootDir>/node_modules/neotraverse/dist/legacy/legacy.cjs",
},
};
const bodyExamplesTest =
"<rootDir>/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/jsonExamples.test.ts";
const bodyContentTypesTest =
"<rootDir>/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/index.test.ts";
const requestBodyTest =
"<rootDir>/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/buildPostmanRequest.consumer.test.ts";
const samplerModule =
"docusaurus-plugin-openapi-docs/lib/openapi/createSchemaExample";
const samplerSource =
"packages/docusaurus-plugin-openapi-docs/src/openapi/createSchemaExample.ts";
const bodyConfig = {
...config,
globals: {
"ts-jest": {
...config.globals["ts-jest"],
tsconfig: {
...config.globals["ts-jest"].tsconfig,
allowJs: true,
paths: {
...config.globals["ts-jest"].tsconfig.paths,
[samplerModule]: [samplerSource],
},
},
},
},
transform: {
"[/\\\\]ApiExplorer[/\\\\]Body[/\\\\]json2xml\\.js$": "ts-jest",
},
moduleNameMapper: {
...config.moduleNameMapper,
[`^${samplerModule}$`]: `<rootDir>/${samplerSource}`,
},
};
module.exports = {
projects: [
{
...config,
displayName: "default",
testPathIgnorePatterns: [
"/node_modules/",
bodyExamplesTest.replace(/\./g, "\\.") + "$",
bodyContentTypesTest.replace(/\./g, "\\.") + "$",
requestBodyTest.replace(/\./g, "\\.") + "$",
],
},
{
...config,
displayName: "request-body",
testEnvironment: "jsdom",
testMatch: [requestBodyTest],
},
{
...bodyConfig,
displayName: "body-examples",
testEnvironment: "jsdom",
testMatch: [bodyExamplesTest],
},
{
...bodyConfig,
displayName: "body-content-types",
testMatch: [bodyContentTypesTest],
},
],
};