@akanjs/test 0.0.78 → 0.0.80
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/jest.config.base.d.ts +3 -0
- package/jest.config.base.js +88 -0
- package/jest.config.base.mjs +59 -0
- package/{src/jest.setupFilesAfterEnv.mjs → jest.setupFilesAfterEnv.mjs} +1 -1
- package/package.json +22 -1
- package/src/jest.config.base.d.ts +0 -2
- package/src/jest.config.base.js +0 -51
- package/src/jest.config.base.mjs +0 -32
- /package/{src/jest.globalSetup.d.ts → jest.globalSetup.d.ts} +0 -0
- /package/{src/jest.globalSetup.js → jest.globalSetup.js} +0 -0
- /package/{src/jest.globalSetup.mjs → jest.globalSetup.mjs} +0 -0
- /package/{src/jest.globalTeardown.d.ts → jest.globalTeardown.d.ts} +0 -0
- /package/{src/jest.globalTeardown.js → jest.globalTeardown.js} +0 -0
- /package/{src/jest.globalTeardown.mjs → jest.globalTeardown.mjs} +0 -0
- /package/{src/jest.setupFilesAfterEnv.d.ts → jest.setupFilesAfterEnv.d.ts} +0 -0
- /package/{src/jest.setupFilesAfterEnv.js → jest.setupFilesAfterEnv.js} +0 -0
- /package/{src/jest.testServer.d.ts → jest.testServer.d.ts} +0 -0
- /package/{src/jest.testServer.js → jest.testServer.js} +0 -0
- /package/{src/jest.testServer.mjs → jest.testServer.mjs} +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
var jest_config_base_exports = {};
|
|
29
|
+
__export(jest_config_base_exports, {
|
|
30
|
+
pathsToModuleNameMapper: () => pathsToModuleNameMapper,
|
|
31
|
+
withBase: () => withBase
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(jest_config_base_exports);
|
|
34
|
+
var import_dotenv = require("dotenv");
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
function pathsToModuleNameMapper(paths, workspaceRoot) {
|
|
37
|
+
const moduleNameMapper = {};
|
|
38
|
+
const sortedPaths = Object.entries(paths).sort(([a], [b]) => {
|
|
39
|
+
const aHasWildcard = a.includes("*");
|
|
40
|
+
const bHasWildcard = b.includes("*");
|
|
41
|
+
if (aHasWildcard === bHasWildcard)
|
|
42
|
+
return 0;
|
|
43
|
+
return aHasWildcard ? -1 : 1;
|
|
44
|
+
});
|
|
45
|
+
for (const [tsPath, targetPaths] of sortedPaths) {
|
|
46
|
+
const targetPath = targetPaths[0];
|
|
47
|
+
const escapedPath = tsPath.replace(/[.*+?^${}()|[\]\\]/g, (match) => {
|
|
48
|
+
return match === "*" ? match : `\\${match}`;
|
|
49
|
+
});
|
|
50
|
+
const jestPattern = `^${escapedPath.replace(/\*/g, "(.*)")}$`;
|
|
51
|
+
const jestReplacement = `${workspaceRoot}/${targetPath.replace(/\*/g, "$1")}`;
|
|
52
|
+
moduleNameMapper[jestPattern] = jestReplacement;
|
|
53
|
+
}
|
|
54
|
+
return moduleNameMapper;
|
|
55
|
+
}
|
|
56
|
+
const withBase = (name) => {
|
|
57
|
+
(0, import_dotenv.config)();
|
|
58
|
+
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
59
|
+
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
60
|
+
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
61
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
62
|
+
const workspaceRoot = process.env.AKAN_WORKSPACE_ROOT ?? process.cwd();
|
|
63
|
+
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${workspaceRoot}/pkgs/` : "";
|
|
64
|
+
const tsconfigPath = `${workspaceRoot}/tsconfig.json`;
|
|
65
|
+
const tsconfig = JSON.parse(import_fs.default.readFileSync(tsconfigPath, "utf8"));
|
|
66
|
+
const paths = tsconfig.compilerOptions?.paths ?? {};
|
|
67
|
+
return {
|
|
68
|
+
displayName: name,
|
|
69
|
+
moduleNameMapper: pathsToModuleNameMapper(paths, workspaceRoot),
|
|
70
|
+
globalSetup: `${akanjsPrefix}@akanjs/test/jest.globalSetup.ts`,
|
|
71
|
+
setupFilesAfterEnv: [`${akanjsPrefix}@akanjs/test/jest.setupFilesAfterEnv.ts`],
|
|
72
|
+
globalTeardown: `${akanjsPrefix}@akanjs/test/jest.globalTeardown.ts`,
|
|
73
|
+
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
74
|
+
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
75
|
+
maxWorkers: 1,
|
|
76
|
+
transform: {
|
|
77
|
+
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
78
|
+
"^.+\\.(ts|js|html)$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
79
|
+
},
|
|
80
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
81
|
+
coverageDirectory: `../../coverage/libs/${name}`,
|
|
82
|
+
coverageReporters: ["html"],
|
|
83
|
+
testEnvironment: "node",
|
|
84
|
+
testEnvironmentOptions: {
|
|
85
|
+
customExportConditions: ["node", "require", "default"]
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { config } from "dotenv";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
function pathsToModuleNameMapper(paths, workspaceRoot) {
|
|
4
|
+
const moduleNameMapper = {};
|
|
5
|
+
const sortedPaths = Object.entries(paths).sort(([a], [b]) => {
|
|
6
|
+
const aHasWildcard = a.includes("*");
|
|
7
|
+
const bHasWildcard = b.includes("*");
|
|
8
|
+
if (aHasWildcard === bHasWildcard)
|
|
9
|
+
return 0;
|
|
10
|
+
return aHasWildcard ? -1 : 1;
|
|
11
|
+
});
|
|
12
|
+
for (const [tsPath, targetPaths] of sortedPaths) {
|
|
13
|
+
const targetPath = targetPaths[0];
|
|
14
|
+
const escapedPath = tsPath.replace(/[.*+?^${}()|[\]\\]/g, (match) => {
|
|
15
|
+
return match === "*" ? match : `\\${match}`;
|
|
16
|
+
});
|
|
17
|
+
const jestPattern = `^${escapedPath.replace(/\*/g, "(.*)")}$`;
|
|
18
|
+
const jestReplacement = `${workspaceRoot}/${targetPath.replace(/\*/g, "$1")}`;
|
|
19
|
+
moduleNameMapper[jestPattern] = jestReplacement;
|
|
20
|
+
}
|
|
21
|
+
return moduleNameMapper;
|
|
22
|
+
}
|
|
23
|
+
const withBase = (name) => {
|
|
24
|
+
config();
|
|
25
|
+
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
26
|
+
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
27
|
+
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
28
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
29
|
+
const workspaceRoot = process.env.AKAN_WORKSPACE_ROOT ?? process.cwd();
|
|
30
|
+
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${workspaceRoot}/pkgs/` : "";
|
|
31
|
+
const tsconfigPath = `${workspaceRoot}/tsconfig.json`;
|
|
32
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
|
|
33
|
+
const paths = tsconfig.compilerOptions?.paths ?? {};
|
|
34
|
+
return {
|
|
35
|
+
displayName: name,
|
|
36
|
+
moduleNameMapper: pathsToModuleNameMapper(paths, workspaceRoot),
|
|
37
|
+
globalSetup: `${akanjsPrefix}@akanjs/test/jest.globalSetup.ts`,
|
|
38
|
+
setupFilesAfterEnv: [`${akanjsPrefix}@akanjs/test/jest.setupFilesAfterEnv.ts`],
|
|
39
|
+
globalTeardown: `${akanjsPrefix}@akanjs/test/jest.globalTeardown.ts`,
|
|
40
|
+
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
41
|
+
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
42
|
+
maxWorkers: 1,
|
|
43
|
+
transform: {
|
|
44
|
+
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
45
|
+
"^.+\\.(ts|js|html)$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
46
|
+
},
|
|
47
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
48
|
+
coverageDirectory: `../../coverage/libs/${name}`,
|
|
49
|
+
coverageReporters: ["html"],
|
|
50
|
+
testEnvironment: "node",
|
|
51
|
+
testEnvironmentOptions: {
|
|
52
|
+
customExportConditions: ["node", "require", "default"]
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
pathsToModuleNameMapper,
|
|
58
|
+
withBase
|
|
59
|
+
};
|
|
@@ -4,7 +4,7 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
4
4
|
};
|
|
5
5
|
import { TestServer } from "./jest.testServer";
|
|
6
6
|
var require_jest_setupFilesAfterEnv = __commonJS({
|
|
7
|
-
"pkgs/@akanjs/test/
|
|
7
|
+
"pkgs/@akanjs/test/jest.setupFilesAfterEnv.ts"() {
|
|
8
8
|
const { env, fetch } = global;
|
|
9
9
|
jest.setTimeout(3e4);
|
|
10
10
|
global.beforeAll(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/test",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,12 +22,33 @@
|
|
|
22
22
|
"mongodb-memory-server": "^10.1.3",
|
|
23
23
|
"mongoose": "^8.9.3",
|
|
24
24
|
"redis-memory-server": "^0.11.0",
|
|
25
|
+
"ts-jest": "^29.2.5",
|
|
25
26
|
"tsconfig-paths": "^4.2.0"
|
|
26
27
|
},
|
|
27
28
|
"exports": {
|
|
28
29
|
".": {
|
|
29
30
|
"require": "./index.js",
|
|
30
31
|
"import": "./index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./jest.config.base": {
|
|
34
|
+
"require": "./jest.config.base.js",
|
|
35
|
+
"import": "./jest.config.base.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./jest.testServer": {
|
|
38
|
+
"require": "./jest.testServer.js",
|
|
39
|
+
"import": "./jest.testServer.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./jest.globalSetup": {
|
|
42
|
+
"require": "./jest.globalSetup.js",
|
|
43
|
+
"import": "./jest.globalSetup.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./jest.globalTeardown": {
|
|
46
|
+
"require": "./jest.globalTeardown.js",
|
|
47
|
+
"import": "./jest.globalTeardown.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./jest.setupFilesAfterEnv": {
|
|
50
|
+
"require": "./jest.setupFilesAfterEnv.js",
|
|
51
|
+
"import": "./jest.setupFilesAfterEnv.mjs"
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
54
|
}
|
package/src/jest.config.base.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var jest_config_base_exports = {};
|
|
19
|
-
__export(jest_config_base_exports, {
|
|
20
|
-
withBase: () => withBase
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(jest_config_base_exports);
|
|
23
|
-
var import_dotenv = require("dotenv");
|
|
24
|
-
const withBase = (name) => {
|
|
25
|
-
(0, import_dotenv.config)();
|
|
26
|
-
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
27
|
-
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
28
|
-
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
29
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
30
|
-
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/" : "";
|
|
31
|
-
return {
|
|
32
|
-
displayName: name,
|
|
33
|
-
globalSetup: `${akanjsPrefix}@akanjs/test/src/jest.globalSetup.ts`,
|
|
34
|
-
setupFilesAfterEnv: [`${akanjsPrefix}@akanjs/test/src/jest.setupFilesAfterEnv.ts`],
|
|
35
|
-
globalTeardown: `${akanjsPrefix}@akanjs/test/src/jest.globalTeardown.ts`,
|
|
36
|
-
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
37
|
-
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
38
|
-
maxWorkers: 1,
|
|
39
|
-
transform: {
|
|
40
|
-
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
41
|
-
"^.+\\.(ts|js|html)$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
42
|
-
},
|
|
43
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
44
|
-
coverageDirectory: `../../coverage/libs/${name}`,
|
|
45
|
-
coverageReporters: ["html"],
|
|
46
|
-
testEnvironment: "node",
|
|
47
|
-
testEnvironmentOptions: {
|
|
48
|
-
customExportConditions: ["node", "require", "default"]
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
package/src/jest.config.base.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
const withBase = (name) => {
|
|
3
|
-
config();
|
|
4
|
-
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
5
|
-
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
6
|
-
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
7
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
8
|
-
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/" : "";
|
|
9
|
-
return {
|
|
10
|
-
displayName: name,
|
|
11
|
-
globalSetup: `${akanjsPrefix}@akanjs/test/src/jest.globalSetup.ts`,
|
|
12
|
-
setupFilesAfterEnv: [`${akanjsPrefix}@akanjs/test/src/jest.setupFilesAfterEnv.ts`],
|
|
13
|
-
globalTeardown: `${akanjsPrefix}@akanjs/test/src/jest.globalTeardown.ts`,
|
|
14
|
-
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
15
|
-
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
16
|
-
maxWorkers: 1,
|
|
17
|
-
transform: {
|
|
18
|
-
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
19
|
-
"^.+\\.(ts|js|html)$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
20
|
-
},
|
|
21
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
22
|
-
coverageDirectory: `../../coverage/libs/${name}`,
|
|
23
|
-
coverageReporters: ["html"],
|
|
24
|
-
testEnvironment: "node",
|
|
25
|
-
testEnvironmentOptions: {
|
|
26
|
-
customExportConditions: ["node", "require", "default"]
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
withBase
|
|
32
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|