@storm-software/testing-tools 1.112.1 → 1.113.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.
- package/README.md +1 -1
- package/dist/index.cjs +125 -7
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +112 -6
- package/dist/jest/{config/package.cjs → declare-package.cjs} +10 -10
- package/dist/jest/declare-package.d.cts +18 -0
- package/dist/jest/declare-package.d.ts +18 -0
- package/dist/jest/declare-package.js +17 -0
- package/dist/jest/declare-preset.cjs +79 -0
- package/dist/jest/declare-preset.d.cts +5 -0
- package/dist/jest/declare-preset.d.ts +5 -0
- package/dist/jest/declare-preset.js +45 -0
- package/dist/jest/declare-workspace.cjs +97 -0
- package/dist/jest/declare-workspace.d.cts +10 -0
- package/dist/jest/declare-workspace.d.ts +10 -0
- package/dist/jest/{config/workspace.d.ts → declare-workspace.js} +34 -19
- package/dist/jest/{config/preset.cjs → preset/index.cjs} +49 -25
- package/dist/jest/preset/index.d.cts +5 -0
- package/dist/jest/preset/index.d.ts +5 -0
- package/dist/jest/preset/index.js +51 -0
- package/dist/jest/preset/jest-preset.cjs +84 -0
- package/dist/jest/{config/preset.d.cts → preset/jest-preset.d.cts} +37 -23
- package/dist/jest/{config/preset.d.ts → preset/jest-preset.d.ts} +37 -23
- package/dist/jest/preset/jest-preset.js +48 -0
- package/package.json +52 -23
- package/dist/jest/config/package.d.cts +0 -15
- package/dist/jest/config/package.d.ts +0 -15
- package/dist/jest/config/package.js +0 -17
- package/dist/jest/config/preset.js +0 -29
- package/dist/jest/config/workspace.cjs +0 -74
- package/dist/jest/config/workspace.d.cts +0 -48
- package/dist/jest/config/workspace.js +0 -54
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,30 +16,146 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/index.ts
|
|
20
30
|
var index_exports = {};
|
|
21
31
|
__export(index_exports, {
|
|
22
|
-
|
|
32
|
+
declarePackage: () => declarePackage,
|
|
33
|
+
declarePreset: () => declarePreset,
|
|
34
|
+
declareWorkspace: () => declareWorkspace
|
|
23
35
|
});
|
|
24
36
|
module.exports = __toCommonJS(index_exports);
|
|
25
37
|
|
|
26
|
-
// src/jest/
|
|
38
|
+
// src/jest/declare-package.ts
|
|
27
39
|
var import_node_path = require("path");
|
|
28
|
-
function
|
|
40
|
+
function declarePackage(options) {
|
|
29
41
|
return {
|
|
30
|
-
displayName: displayName ? displayName :
|
|
42
|
+
displayName: options.displayName ? options.displayName : options.projectRoot.replaceAll("\\", "-").replaceAll("/", "-"),
|
|
31
43
|
preset: "@storm-software/testing-tools/jest/preset",
|
|
32
|
-
testEnvironment: isNode ? "node" : "jsdom",
|
|
44
|
+
testEnvironment: options.isNode ? "node" : "jsdom",
|
|
33
45
|
transform: {
|
|
34
46
|
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
35
47
|
},
|
|
36
48
|
moduleFileExtensions: ["ts", "js", "html"],
|
|
37
|
-
coverageDirectory: (0, import_node_path.join)("
|
|
49
|
+
coverageDirectory: (0, import_node_path.join)("<rootDir>/coverage", options.projectRoot)
|
|
38
50
|
};
|
|
39
51
|
}
|
|
52
|
+
|
|
53
|
+
// src/jest/declare-preset.ts
|
|
54
|
+
var import_preset = __toESM(require("@nx/jest/preset"), 1);
|
|
55
|
+
var import_defu = __toESM(require("defu"), 1);
|
|
56
|
+
function declarePreset(config = {}) {
|
|
57
|
+
return (0, import_defu.default)(
|
|
58
|
+
config,
|
|
59
|
+
{
|
|
60
|
+
collectCoverage: true,
|
|
61
|
+
testTimeout: 3e4,
|
|
62
|
+
clearMocks: true,
|
|
63
|
+
testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
|
|
64
|
+
transform: {
|
|
65
|
+
"^.+\\.(ts|js|mts|mjs|cts|cjs|html)$": [
|
|
66
|
+
"ts-jest",
|
|
67
|
+
{ tsconfig: "<rootDir>/tsconfig.spec.json" }
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
snapshotFormat: {
|
|
71
|
+
printBasicPrototype: false
|
|
72
|
+
},
|
|
73
|
+
globals: {
|
|
74
|
+
"ts-jest": {
|
|
75
|
+
isolatedModules: true,
|
|
76
|
+
diagnostics: {
|
|
77
|
+
exclude: ["**"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
82
|
+
coverageReporters: [
|
|
83
|
+
"json",
|
|
84
|
+
"lcov",
|
|
85
|
+
"text",
|
|
86
|
+
"clover",
|
|
87
|
+
"text-summary",
|
|
88
|
+
"html"
|
|
89
|
+
],
|
|
90
|
+
maxWorkers: 1
|
|
91
|
+
},
|
|
92
|
+
import_preset.default ?? {}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/jest/declare-workspace.ts
|
|
97
|
+
var import_jest = require("@nx/jest");
|
|
98
|
+
var import_defu2 = __toESM(require("defu"), 1);
|
|
99
|
+
function declareWorkspace(config = {}) {
|
|
100
|
+
return async () => (0, import_defu2.default)(config, {
|
|
101
|
+
/**
|
|
102
|
+
* When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time.
|
|
103
|
+
* This is great for monorepos or when working on multiple projects at the same time.
|
|
104
|
+
*/
|
|
105
|
+
projects: [...await (0, import_jest.getJestProjectsAsync)(), "<rootDir>/jest.config.ts"],
|
|
106
|
+
/**
|
|
107
|
+
* Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
|
|
108
|
+
* executed files with coverage collection statements, it may significantly slow down your tests. Default: false
|
|
109
|
+
*/
|
|
110
|
+
collectCoverage: process.env.CI ? true : false,
|
|
111
|
+
/**
|
|
112
|
+
* An array of glob patterns indicating a set of files for which coverage information should be collected.
|
|
113
|
+
* If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
|
|
114
|
+
* for this file and it's never required in the test suite. Default: undefined
|
|
115
|
+
*/
|
|
116
|
+
// collectCoverageFrom: ["**/*(!*.spec).tsx", "**/*(!*.spec).ts"],
|
|
117
|
+
/**
|
|
118
|
+
* The directory where Jest should output its coverage files. Default: undefined
|
|
119
|
+
*/
|
|
120
|
+
coverageDirectory: "<rootDir>/coverage",
|
|
121
|
+
/**
|
|
122
|
+
* An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path
|
|
123
|
+
* matches any of the patterns, coverage information will be skipped.
|
|
124
|
+
*/
|
|
125
|
+
coveragePathIgnorePatterns: [
|
|
126
|
+
"\\.spec\\.ts$",
|
|
127
|
+
"\\.test\\.ts$",
|
|
128
|
+
"<rootDir>/dist",
|
|
129
|
+
"<rootDir>/tests",
|
|
130
|
+
"<rootDir>/__generated__",
|
|
131
|
+
"<rootDir>/node_modules"
|
|
132
|
+
],
|
|
133
|
+
/**
|
|
134
|
+
* The test environment that will be used for testing. The default environment in Jest is a Node.js environment.
|
|
135
|
+
* If you are building a web app, you can use a browser-like environment through jsdom instead.
|
|
136
|
+
*/
|
|
137
|
+
testEnvironment: "jest-environment-jsdom",
|
|
138
|
+
/**
|
|
139
|
+
* A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
|
|
140
|
+
* Default: ["json", "lcov", "text"]
|
|
141
|
+
*/
|
|
142
|
+
coverageReporters: ["lcov", "json"],
|
|
143
|
+
/**
|
|
144
|
+
* Setup files that run before each test suite.
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* This is useful for setting up global variables or configurations that your tests need.
|
|
148
|
+
*/
|
|
149
|
+
setupFiles: ["./node_modules/@storm-software/testing-tools/jest/setup"],
|
|
150
|
+
moduleNameMapper: {
|
|
151
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "@storm-software/testing-tools/jest/__mocks__/file.mock.js",
|
|
152
|
+
"\\.(css|less)$": "@storm-software/testing-tools/jest/__mocks__/style.mock.js"
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
40
156
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
157
|
0 && (module.exports = {
|
|
42
|
-
|
|
158
|
+
declarePackage,
|
|
159
|
+
declarePreset,
|
|
160
|
+
declareWorkspace
|
|
43
161
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DeclarePackageConfigOptions, declarePackage } from './jest/declare-package.cjs';
|
|
2
|
+
export { declarePreset } from './jest/declare-preset.cjs';
|
|
3
|
+
export { declareWorkspace } from './jest/declare-workspace.cjs';
|
|
2
4
|
import 'jest';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DeclarePackageConfigOptions, declarePackage } from './jest/declare-package.js';
|
|
2
|
+
export { declarePreset } from './jest/declare-preset.js';
|
|
3
|
+
export { declareWorkspace } from './jest/declare-workspace.js';
|
|
2
4
|
import 'jest';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,123 @@
|
|
|
1
|
-
// src/jest/
|
|
1
|
+
// src/jest/declare-package.ts
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
function
|
|
3
|
+
function declarePackage(options) {
|
|
4
4
|
return {
|
|
5
|
-
displayName: displayName ? displayName :
|
|
5
|
+
displayName: options.displayName ? options.displayName : options.projectRoot.replaceAll("\\", "-").replaceAll("/", "-"),
|
|
6
6
|
preset: "@storm-software/testing-tools/jest/preset",
|
|
7
|
-
testEnvironment: isNode ? "node" : "jsdom",
|
|
7
|
+
testEnvironment: options.isNode ? "node" : "jsdom",
|
|
8
8
|
transform: {
|
|
9
9
|
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
10
10
|
},
|
|
11
11
|
moduleFileExtensions: ["ts", "js", "html"],
|
|
12
|
-
coverageDirectory: join("
|
|
12
|
+
coverageDirectory: join("<rootDir>/coverage", options.projectRoot)
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
// src/jest/declare-preset.ts
|
|
17
|
+
import nxPreset from "@nx/jest/preset";
|
|
18
|
+
import defu from "defu";
|
|
19
|
+
function declarePreset(config = {}) {
|
|
20
|
+
return defu(
|
|
21
|
+
config,
|
|
22
|
+
{
|
|
23
|
+
collectCoverage: true,
|
|
24
|
+
testTimeout: 3e4,
|
|
25
|
+
clearMocks: true,
|
|
26
|
+
testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
|
|
27
|
+
transform: {
|
|
28
|
+
"^.+\\.(ts|js|mts|mjs|cts|cjs|html)$": [
|
|
29
|
+
"ts-jest",
|
|
30
|
+
{ tsconfig: "<rootDir>/tsconfig.spec.json" }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
snapshotFormat: {
|
|
34
|
+
printBasicPrototype: false
|
|
35
|
+
},
|
|
36
|
+
globals: {
|
|
37
|
+
"ts-jest": {
|
|
38
|
+
isolatedModules: true,
|
|
39
|
+
diagnostics: {
|
|
40
|
+
exclude: ["**"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
45
|
+
coverageReporters: [
|
|
46
|
+
"json",
|
|
47
|
+
"lcov",
|
|
48
|
+
"text",
|
|
49
|
+
"clover",
|
|
50
|
+
"text-summary",
|
|
51
|
+
"html"
|
|
52
|
+
],
|
|
53
|
+
maxWorkers: 1
|
|
54
|
+
},
|
|
55
|
+
nxPreset ?? {}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/jest/declare-workspace.ts
|
|
60
|
+
import { getJestProjectsAsync } from "@nx/jest";
|
|
61
|
+
import defu2 from "defu";
|
|
62
|
+
function declareWorkspace(config = {}) {
|
|
63
|
+
return async () => defu2(config, {
|
|
64
|
+
/**
|
|
65
|
+
* When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time.
|
|
66
|
+
* This is great for monorepos or when working on multiple projects at the same time.
|
|
67
|
+
*/
|
|
68
|
+
projects: [...await getJestProjectsAsync(), "<rootDir>/jest.config.ts"],
|
|
69
|
+
/**
|
|
70
|
+
* Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
|
|
71
|
+
* executed files with coverage collection statements, it may significantly slow down your tests. Default: false
|
|
72
|
+
*/
|
|
73
|
+
collectCoverage: process.env.CI ? true : false,
|
|
74
|
+
/**
|
|
75
|
+
* An array of glob patterns indicating a set of files for which coverage information should be collected.
|
|
76
|
+
* If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
|
|
77
|
+
* for this file and it's never required in the test suite. Default: undefined
|
|
78
|
+
*/
|
|
79
|
+
// collectCoverageFrom: ["**/*(!*.spec).tsx", "**/*(!*.spec).ts"],
|
|
80
|
+
/**
|
|
81
|
+
* The directory where Jest should output its coverage files. Default: undefined
|
|
82
|
+
*/
|
|
83
|
+
coverageDirectory: "<rootDir>/coverage",
|
|
84
|
+
/**
|
|
85
|
+
* An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path
|
|
86
|
+
* matches any of the patterns, coverage information will be skipped.
|
|
87
|
+
*/
|
|
88
|
+
coveragePathIgnorePatterns: [
|
|
89
|
+
"\\.spec\\.ts$",
|
|
90
|
+
"\\.test\\.ts$",
|
|
91
|
+
"<rootDir>/dist",
|
|
92
|
+
"<rootDir>/tests",
|
|
93
|
+
"<rootDir>/__generated__",
|
|
94
|
+
"<rootDir>/node_modules"
|
|
95
|
+
],
|
|
96
|
+
/**
|
|
97
|
+
* The test environment that will be used for testing. The default environment in Jest is a Node.js environment.
|
|
98
|
+
* If you are building a web app, you can use a browser-like environment through jsdom instead.
|
|
99
|
+
*/
|
|
100
|
+
testEnvironment: "jest-environment-jsdom",
|
|
101
|
+
/**
|
|
102
|
+
* A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
|
|
103
|
+
* Default: ["json", "lcov", "text"]
|
|
104
|
+
*/
|
|
105
|
+
coverageReporters: ["lcov", "json"],
|
|
106
|
+
/**
|
|
107
|
+
* Setup files that run before each test suite.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* This is useful for setting up global variables or configurations that your tests need.
|
|
111
|
+
*/
|
|
112
|
+
setupFiles: ["./node_modules/@storm-software/testing-tools/jest/setup"],
|
|
113
|
+
moduleNameMapper: {
|
|
114
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "@storm-software/testing-tools/jest/__mocks__/file.mock.js",
|
|
115
|
+
"\\.(css|less)$": "@storm-software/testing-tools/jest/__mocks__/style.mock.js"
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
15
119
|
export {
|
|
16
|
-
|
|
120
|
+
declarePackage,
|
|
121
|
+
declarePreset,
|
|
122
|
+
declareWorkspace
|
|
17
123
|
};
|
|
@@ -16,26 +16,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/jest/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
19
|
+
// src/jest/declare-package.ts
|
|
20
|
+
var declare_package_exports = {};
|
|
21
|
+
__export(declare_package_exports, {
|
|
22
|
+
declarePackage: () => declarePackage
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(declare_package_exports);
|
|
25
25
|
var import_node_path = require("path");
|
|
26
|
-
function
|
|
26
|
+
function declarePackage(options) {
|
|
27
27
|
return {
|
|
28
|
-
displayName: displayName ? displayName :
|
|
28
|
+
displayName: options.displayName ? options.displayName : options.projectRoot.replaceAll("\\", "-").replaceAll("/", "-"),
|
|
29
29
|
preset: "@storm-software/testing-tools/jest/preset",
|
|
30
|
-
testEnvironment: isNode ? "node" : "jsdom",
|
|
30
|
+
testEnvironment: options.isNode ? "node" : "jsdom",
|
|
31
31
|
transform: {
|
|
32
32
|
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
33
33
|
},
|
|
34
34
|
moduleFileExtensions: ["ts", "js", "html"],
|
|
35
|
-
coverageDirectory: (0, import_node_path.join)("
|
|
35
|
+
coverageDirectory: (0, import_node_path.join)("<rootDir>/coverage", options.projectRoot)
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
39
|
0 && (module.exports = {
|
|
40
|
-
|
|
40
|
+
declarePackage
|
|
41
41
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
type DeclarePackageConfigOptions = Config & {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
isNode?: boolean;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Config for Jest unit tests
|
|
10
|
+
*
|
|
11
|
+
* @remarks Please see [the Jest documentation](https://jestjs.io/docs/configuration#projects-arraystring--projectconfig) for more information.
|
|
12
|
+
*
|
|
13
|
+
* @param options The options for the Jest configuration
|
|
14
|
+
* @returns The Jest configuration
|
|
15
|
+
*/
|
|
16
|
+
declare function declarePackage(options: DeclarePackageConfigOptions): Config;
|
|
17
|
+
|
|
18
|
+
export { type DeclarePackageConfigOptions, declarePackage };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
type DeclarePackageConfigOptions = Config & {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
isNode?: boolean;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Config for Jest unit tests
|
|
10
|
+
*
|
|
11
|
+
* @remarks Please see [the Jest documentation](https://jestjs.io/docs/configuration#projects-arraystring--projectconfig) for more information.
|
|
12
|
+
*
|
|
13
|
+
* @param options The options for the Jest configuration
|
|
14
|
+
* @returns The Jest configuration
|
|
15
|
+
*/
|
|
16
|
+
declare function declarePackage(options: DeclarePackageConfigOptions): Config;
|
|
17
|
+
|
|
18
|
+
export { type DeclarePackageConfigOptions, declarePackage };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/jest/declare-package.ts
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
function declarePackage(options) {
|
|
4
|
+
return {
|
|
5
|
+
displayName: options.displayName ? options.displayName : options.projectRoot.replaceAll("\\", "-").replaceAll("/", "-"),
|
|
6
|
+
preset: "@storm-software/testing-tools/jest/preset",
|
|
7
|
+
testEnvironment: options.isNode ? "node" : "jsdom",
|
|
8
|
+
transform: {
|
|
9
|
+
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
10
|
+
},
|
|
11
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
12
|
+
coverageDirectory: join("<rootDir>/coverage", options.projectRoot)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
declarePackage
|
|
17
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/jest/declare-preset.ts
|
|
30
|
+
var declare_preset_exports = {};
|
|
31
|
+
__export(declare_preset_exports, {
|
|
32
|
+
declarePreset: () => declarePreset
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(declare_preset_exports);
|
|
35
|
+
var import_preset = __toESM(require("@nx/jest/preset"), 1);
|
|
36
|
+
var import_defu = __toESM(require("defu"), 1);
|
|
37
|
+
function declarePreset(config = {}) {
|
|
38
|
+
return (0, import_defu.default)(
|
|
39
|
+
config,
|
|
40
|
+
{
|
|
41
|
+
collectCoverage: true,
|
|
42
|
+
testTimeout: 3e4,
|
|
43
|
+
clearMocks: true,
|
|
44
|
+
testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
|
|
45
|
+
transform: {
|
|
46
|
+
"^.+\\.(ts|js|mts|mjs|cts|cjs|html)$": [
|
|
47
|
+
"ts-jest",
|
|
48
|
+
{ tsconfig: "<rootDir>/tsconfig.spec.json" }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
snapshotFormat: {
|
|
52
|
+
printBasicPrototype: false
|
|
53
|
+
},
|
|
54
|
+
globals: {
|
|
55
|
+
"ts-jest": {
|
|
56
|
+
isolatedModules: true,
|
|
57
|
+
diagnostics: {
|
|
58
|
+
exclude: ["**"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
63
|
+
coverageReporters: [
|
|
64
|
+
"json",
|
|
65
|
+
"lcov",
|
|
66
|
+
"text",
|
|
67
|
+
"clover",
|
|
68
|
+
"text-summary",
|
|
69
|
+
"html"
|
|
70
|
+
],
|
|
71
|
+
maxWorkers: 1
|
|
72
|
+
},
|
|
73
|
+
import_preset.default ?? {}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
declarePreset
|
|
79
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/jest/declare-preset.ts
|
|
2
|
+
import nxPreset from "@nx/jest/preset";
|
|
3
|
+
import defu from "defu";
|
|
4
|
+
function declarePreset(config = {}) {
|
|
5
|
+
return defu(
|
|
6
|
+
config,
|
|
7
|
+
{
|
|
8
|
+
collectCoverage: true,
|
|
9
|
+
testTimeout: 3e4,
|
|
10
|
+
clearMocks: true,
|
|
11
|
+
testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
|
|
12
|
+
transform: {
|
|
13
|
+
"^.+\\.(ts|js|mts|mjs|cts|cjs|html)$": [
|
|
14
|
+
"ts-jest",
|
|
15
|
+
{ tsconfig: "<rootDir>/tsconfig.spec.json" }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
snapshotFormat: {
|
|
19
|
+
printBasicPrototype: false
|
|
20
|
+
},
|
|
21
|
+
globals: {
|
|
22
|
+
"ts-jest": {
|
|
23
|
+
isolatedModules: true,
|
|
24
|
+
diagnostics: {
|
|
25
|
+
exclude: ["**"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
moduleFileExtensions: ["ts", "js", "html"],
|
|
30
|
+
coverageReporters: [
|
|
31
|
+
"json",
|
|
32
|
+
"lcov",
|
|
33
|
+
"text",
|
|
34
|
+
"clover",
|
|
35
|
+
"text-summary",
|
|
36
|
+
"html"
|
|
37
|
+
],
|
|
38
|
+
maxWorkers: 1
|
|
39
|
+
},
|
|
40
|
+
nxPreset ?? {}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
declarePreset
|
|
45
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/jest/declare-workspace.ts
|
|
30
|
+
var declare_workspace_exports = {};
|
|
31
|
+
__export(declare_workspace_exports, {
|
|
32
|
+
declareWorkspace: () => declareWorkspace
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(declare_workspace_exports);
|
|
35
|
+
var import_jest = require("@nx/jest");
|
|
36
|
+
var import_defu = __toESM(require("defu"), 1);
|
|
37
|
+
function declareWorkspace(config = {}) {
|
|
38
|
+
return async () => (0, import_defu.default)(config, {
|
|
39
|
+
/**
|
|
40
|
+
* When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time.
|
|
41
|
+
* This is great for monorepos or when working on multiple projects at the same time.
|
|
42
|
+
*/
|
|
43
|
+
projects: [...await (0, import_jest.getJestProjectsAsync)(), "<rootDir>/jest.config.ts"],
|
|
44
|
+
/**
|
|
45
|
+
* Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
|
|
46
|
+
* executed files with coverage collection statements, it may significantly slow down your tests. Default: false
|
|
47
|
+
*/
|
|
48
|
+
collectCoverage: process.env.CI ? true : false,
|
|
49
|
+
/**
|
|
50
|
+
* An array of glob patterns indicating a set of files for which coverage information should be collected.
|
|
51
|
+
* If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
|
|
52
|
+
* for this file and it's never required in the test suite. Default: undefined
|
|
53
|
+
*/
|
|
54
|
+
// collectCoverageFrom: ["**/*(!*.spec).tsx", "**/*(!*.spec).ts"],
|
|
55
|
+
/**
|
|
56
|
+
* The directory where Jest should output its coverage files. Default: undefined
|
|
57
|
+
*/
|
|
58
|
+
coverageDirectory: "<rootDir>/coverage",
|
|
59
|
+
/**
|
|
60
|
+
* An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path
|
|
61
|
+
* matches any of the patterns, coverage information will be skipped.
|
|
62
|
+
*/
|
|
63
|
+
coveragePathIgnorePatterns: [
|
|
64
|
+
"\\.spec\\.ts$",
|
|
65
|
+
"\\.test\\.ts$",
|
|
66
|
+
"<rootDir>/dist",
|
|
67
|
+
"<rootDir>/tests",
|
|
68
|
+
"<rootDir>/__generated__",
|
|
69
|
+
"<rootDir>/node_modules"
|
|
70
|
+
],
|
|
71
|
+
/**
|
|
72
|
+
* The test environment that will be used for testing. The default environment in Jest is a Node.js environment.
|
|
73
|
+
* If you are building a web app, you can use a browser-like environment through jsdom instead.
|
|
74
|
+
*/
|
|
75
|
+
testEnvironment: "jest-environment-jsdom",
|
|
76
|
+
/**
|
|
77
|
+
* A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
|
|
78
|
+
* Default: ["json", "lcov", "text"]
|
|
79
|
+
*/
|
|
80
|
+
coverageReporters: ["lcov", "json"],
|
|
81
|
+
/**
|
|
82
|
+
* Setup files that run before each test suite.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* This is useful for setting up global variables or configurations that your tests need.
|
|
86
|
+
*/
|
|
87
|
+
setupFiles: ["./node_modules/@storm-software/testing-tools/jest/setup"],
|
|
88
|
+
moduleNameMapper: {
|
|
89
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "@storm-software/testing-tools/jest/__mocks__/file.mock.js",
|
|
90
|
+
"\\.(css|less)$": "@storm-software/testing-tools/jest/__mocks__/style.mock.js"
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
declareWorkspace
|
|
97
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Config for Jest unit tests
|
|
5
|
+
*
|
|
6
|
+
* https://jestjs.io/docs/configuration#projects-arraystring--projectconfig
|
|
7
|
+
*/
|
|
8
|
+
declare function declareWorkspace(config?: Partial<Config>): () => Promise<Config>;
|
|
9
|
+
|
|
10
|
+
export { declareWorkspace };
|