@akanjs/test 0.0.40 → 0.0.42
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/index.d.ts +1 -3
- package/index.js +626 -21
- package/package.json +7 -2
- package/src/index.d.ts +2 -3
- package/src/sample.d.ts +2 -5
- package/src/sampleOf.d.ts +4 -31
- package/src/index.js +0 -30
- package/src/jest.config.base.d.ts +0 -5
- package/src/jest.config.base.js +0 -85
- package/src/jest.globalSetup.d.ts +0 -5
- package/src/jest.globalSetup.js +0 -38
- package/src/jest.globalTeardown.d.ts +0 -3
- package/src/jest.globalTeardown.js +0 -30
- package/src/jest.setupFilesAfterEnv.d.ts +0 -2
- package/src/jest.setupFilesAfterEnv.js +0 -10
- package/src/jest.testServer.d.ts +0 -44
- package/src/jest.testServer.js +0 -160
- package/src/playwright.config.base.d.ts +0 -12
- package/src/playwright.config.base.js +0 -71
- package/src/playwright.pageAgent.d.ts +0 -14
- package/src/playwright.pageAgent.js +0 -74
- package/src/sample.js +0 -50
- package/src/sampleOf.js +0 -110
package/src/sample.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Dayjs } from
|
|
2
|
-
|
|
3
|
-
declare const sample: Chance.Chance & {
|
|
1
|
+
import { Dayjs } from "@akanjs/base";
|
|
2
|
+
export declare const sample: Chance.Chance & {
|
|
4
3
|
dayjs: (opt?: {
|
|
5
4
|
string?: boolean | undefined;
|
|
6
5
|
american?: boolean | undefined;
|
|
@@ -13,5 +12,3 @@ declare const sample: Chance.Chance & {
|
|
|
13
12
|
pick: <T = any>(arr: T[] | readonly T[]) => T;
|
|
14
13
|
picks: <T>(arr: T[] | readonly T[], count?: number, allowDuplicate?: boolean) => T[];
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
export { sample };
|
package/src/sampleOf.d.ts
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
declare class BaseObject {
|
|
6
|
-
id: string;
|
|
7
|
-
createdAt: Dayjs;
|
|
8
|
-
updatedAt: Dayjs;
|
|
9
|
-
removedAt: Dayjs | null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
13
|
-
type OptionalKeys<T> = T extends {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
} ? {
|
|
16
|
-
[K in keyof T]-?: null extends T[K] ? K : never;
|
|
17
|
-
}[keyof T] : never;
|
|
18
|
-
type ObjectToId<O, D = Dayjs> = O extends BaseObject ? string : O extends BaseObject[] ? string[] : O extends Dayjs ? D : O extends {
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
} ? DocumentModel<O> : O;
|
|
21
|
-
type DocumentModel<T, D = Dayjs> = T extends (infer S)[] ? DocumentModel<S>[] : T extends string ? T : T extends number ? T : T extends boolean ? T : T extends Dayjs ? T : T extends Map<infer K, infer V> ? Map<K, DocumentModel<V, D>> : Optional<{
|
|
22
|
-
[K in keyof GetStateObject<T>]: T[K] extends infer S ? S extends null ? undefined : ObjectToId<T[K], D> : never;
|
|
23
|
-
}, OptionalKeys<GetStateObject<T>>>;
|
|
24
|
-
type GetStateObject<T> = Omit<{
|
|
25
|
-
[K in keyof T as T[K] extends (...args: any) => any ? never : K]: T[K];
|
|
26
|
-
}, "prototype">;
|
|
27
|
-
|
|
28
|
-
type SampleOf<Model> = DocumentModel<{
|
|
1
|
+
import { BaseObject, Type } from "@akanjs/base";
|
|
2
|
+
import { DocumentModel } from "@akanjs/constant";
|
|
3
|
+
export type SampleOf<Model> = DocumentModel<{
|
|
29
4
|
[K in keyof Model as Model[K] extends BaseObject ? never : K]: NonNullable<Model[K]>;
|
|
30
5
|
}>;
|
|
31
|
-
declare const sampleOf: <Model>(modelRef: Type<Model>) => DocumentModel<{ [K in keyof Model as Model[K] extends BaseObject ? never : K]: NonNullable<Model[K]>; }>;
|
|
32
|
-
|
|
33
|
-
export { type SampleOf, sampleOf };
|
|
6
|
+
export declare const sampleOf: <Model>(modelRef: Type<Model>) => DocumentModel<{ [K in keyof Model as Model[K] extends BaseObject ? never : K]: NonNullable<Model[K]>; }>;
|
package/src/index.js
DELETED
|
@@ -1,30 +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 src_exports = {};
|
|
19
|
-
__export(src_exports, {
|
|
20
|
-
sample: () => import_sample.sample,
|
|
21
|
-
sampleOf: () => import_sampleOf.sampleOf
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(src_exports);
|
|
24
|
-
var import_sampleOf = require("./sampleOf");
|
|
25
|
-
var import_sample = require("./sample");
|
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
-
0 && (module.exports = {
|
|
28
|
-
sample,
|
|
29
|
-
sampleOf
|
|
30
|
-
});
|
package/src/jest.config.base.js
DELETED
|
@@ -1,85 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 jest_config_base_exports = {};
|
|
20
|
-
__export(jest_config_base_exports, {
|
|
21
|
-
withBase: () => withBase
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(jest_config_base_exports);
|
|
24
|
-
var import_dotenv = require("dotenv");
|
|
25
|
-
const withBase = /* @__PURE__ */ __name((name) => {
|
|
26
|
-
(0, import_dotenv.config)();
|
|
27
|
-
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
28
|
-
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
29
|
-
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
30
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
31
|
-
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/" : "";
|
|
32
|
-
return {
|
|
33
|
-
displayName: name,
|
|
34
|
-
resolver: "@nx/jest/plugins/resolver",
|
|
35
|
-
globalSetup: `${akanjsPrefix}@akanjs/test/src/jest.globalSetup.ts`,
|
|
36
|
-
setupFilesAfterEnv: [
|
|
37
|
-
`${akanjsPrefix}@akanjs/test/src/jest.setupFilesAfterEnv.ts`
|
|
38
|
-
],
|
|
39
|
-
globalTeardown: `${akanjsPrefix}@akanjs/test/src/jest.globalTeardown.ts`,
|
|
40
|
-
testMatch: [
|
|
41
|
-
"**/?(*.)+(test).ts?(x)"
|
|
42
|
-
],
|
|
43
|
-
testPathIgnorePatterns: [
|
|
44
|
-
"/node_modules/",
|
|
45
|
-
"/app/"
|
|
46
|
-
],
|
|
47
|
-
maxWorkers: 1,
|
|
48
|
-
transform: {
|
|
49
|
-
"signal\\.(test)\\.ts$": [
|
|
50
|
-
"ts-jest",
|
|
51
|
-
{
|
|
52
|
-
tsconfig: "<rootDir>/tsconfig.spec.json"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"^.+\\.(ts|js|html)$": [
|
|
56
|
-
"ts-jest",
|
|
57
|
-
{
|
|
58
|
-
tsconfig: "<rootDir>/tsconfig.spec.json"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
moduleFileExtensions: [
|
|
63
|
-
"ts",
|
|
64
|
-
"tsx",
|
|
65
|
-
"js",
|
|
66
|
-
"jsx"
|
|
67
|
-
],
|
|
68
|
-
coverageDirectory: `../../coverage/libs/${name}`,
|
|
69
|
-
coverageReporters: [
|
|
70
|
-
"html"
|
|
71
|
-
],
|
|
72
|
-
testEnvironment: "node",
|
|
73
|
-
testEnvironmentOptions: {
|
|
74
|
-
customExportConditions: [
|
|
75
|
-
"node",
|
|
76
|
-
"require",
|
|
77
|
-
"default"
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, "withBase");
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
withBase
|
|
85
|
-
});
|
package/src/jest.globalSetup.js
DELETED
|
@@ -1,38 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 jest_globalSetup_exports = {};
|
|
20
|
-
__export(jest_globalSetup_exports, {
|
|
21
|
-
default: () => jest_globalSetup_default
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(jest_globalSetup_exports);
|
|
24
|
-
var import_register = require("tsconfig-paths/register");
|
|
25
|
-
var import_jest = require("./jest.testServer");
|
|
26
|
-
const setup = /* @__PURE__ */ __name(async (globalConfig, projectConfig) => {
|
|
27
|
-
const { env } = require(`${globalConfig.rootDir}/env/env.server.testing`);
|
|
28
|
-
const { fetch, registerModules } = require(`${globalConfig.rootDir}/server`);
|
|
29
|
-
const maxWorkers = globalConfig.maxWorkers;
|
|
30
|
-
if (!maxWorkers) throw new Error("maxWorkers is not defined");
|
|
31
|
-
const testServers = new Array(maxWorkers).fill(0).map((_, idx) => new import_jest.TestServer(registerModules, env, idx + 1));
|
|
32
|
-
await Promise.all(testServers.map((server) => server.init()));
|
|
33
|
-
global.__TEST_SERVERS__ = testServers;
|
|
34
|
-
global.fetch = fetch;
|
|
35
|
-
global.env = env;
|
|
36
|
-
global.registerModules = registerModules;
|
|
37
|
-
}, "setup");
|
|
38
|
-
var jest_globalSetup_default = setup;
|
|
@@ -1,30 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 jest_globalTeardown_exports = {};
|
|
20
|
-
__export(jest_globalTeardown_exports, {
|
|
21
|
-
default: () => jest_globalTeardown_default
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(jest_globalTeardown_exports);
|
|
24
|
-
var import_register = require("tsconfig-paths/register");
|
|
25
|
-
const teardown = /* @__PURE__ */ __name(async (globalConfig, projectConfig) => {
|
|
26
|
-
const testServers = global.__TEST_SERVERS__;
|
|
27
|
-
if (!testServers) throw new Error("Test servers are not defined");
|
|
28
|
-
await Promise.all(testServers.map((server) => server.terminate()));
|
|
29
|
-
}, "teardown");
|
|
30
|
-
var jest_globalTeardown_default = teardown;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var import_jest = require("./jest.testServer");
|
|
2
|
-
const { env, fetch } = global;
|
|
3
|
-
jest.setTimeout(3e4);
|
|
4
|
-
global.beforeAll(async () => {
|
|
5
|
-
import_jest.TestServer.initClient(env);
|
|
6
|
-
await fetch.cleanup();
|
|
7
|
-
});
|
|
8
|
-
global.afterAll(async () => {
|
|
9
|
-
await fetch.client.terminate();
|
|
10
|
-
});
|
package/src/jest.testServer.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SshOptions } from 'tunnel-ssh';
|
|
2
|
-
|
|
3
|
-
type Environment = "testing" | "debug" | "develop" | "main";
|
|
4
|
-
interface BaseEnv {
|
|
5
|
-
repoName: string;
|
|
6
|
-
serveDomain: string;
|
|
7
|
-
appName: string;
|
|
8
|
-
environment: Environment;
|
|
9
|
-
operationType: "server" | "client";
|
|
10
|
-
operationMode: "local" | "edge" | "cloud" | "module";
|
|
11
|
-
networkType: "mainnet" | "testnet" | "debugnet";
|
|
12
|
-
tunnelUsername: string;
|
|
13
|
-
tunnelPassword: string;
|
|
14
|
-
}
|
|
15
|
-
type BackendEnv = BaseEnv & {
|
|
16
|
-
hostname: string | null;
|
|
17
|
-
appCode: number;
|
|
18
|
-
mongo: {
|
|
19
|
-
username?: string;
|
|
20
|
-
password?: string;
|
|
21
|
-
sshOptions?: SshOptions;
|
|
22
|
-
};
|
|
23
|
-
redis?: {
|
|
24
|
-
sshOptions?: SshOptions;
|
|
25
|
-
};
|
|
26
|
-
port?: number;
|
|
27
|
-
mongoUri?: string;
|
|
28
|
-
redisUri?: string;
|
|
29
|
-
meiliUri?: string;
|
|
30
|
-
onCleanup?: () => Promise<void>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
declare class TestServer {
|
|
34
|
-
#private;
|
|
35
|
-
workerId: number;
|
|
36
|
-
static initClient(env: BackendEnv, workerId?: number): void;
|
|
37
|
-
constructor(registerModules: (options: any) => any[], env: BackendEnv, workerId?: number);
|
|
38
|
-
init(): Promise<void>;
|
|
39
|
-
startMongo(): Promise<string>;
|
|
40
|
-
cleanup(): Promise<void>;
|
|
41
|
-
terminate(): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { TestServer };
|
package/src/jest.testServer.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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_testServer_exports = {};
|
|
30
|
-
__export(jest_testServer_exports, {
|
|
31
|
-
TestServer: () => TestServer
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(jest_testServer_exports);
|
|
34
|
-
var import_common = require("@akanjs/common");
|
|
35
|
-
var import_server = require("@akanjs/server");
|
|
36
|
-
var import_signal = require("@akanjs/signal");
|
|
37
|
-
var import_mongodb_memory_server = require("mongodb-memory-server");
|
|
38
|
-
var import_mongoose = __toESM(require("mongoose"));
|
|
39
|
-
var import_redis_memory_server = require("redis-memory-server");
|
|
40
|
-
const MAX_RETRY = 5;
|
|
41
|
-
const TEST_LISTEN_PORT_BASE = 38080;
|
|
42
|
-
const TEST_MONGODB_PORT_BASE = 38081;
|
|
43
|
-
const TEST_REDIS_PORT_BASE = 38082;
|
|
44
|
-
const MIN_ACTIVATION_TIME = 0;
|
|
45
|
-
const MAX_ACTIVATION_TIME = 3e4;
|
|
46
|
-
class TestServer {
|
|
47
|
-
static {
|
|
48
|
-
__name(this, "TestServer");
|
|
49
|
-
}
|
|
50
|
-
#logger = new import_common.Logger("TestServer");
|
|
51
|
-
#mongod;
|
|
52
|
-
#redis;
|
|
53
|
-
#registerModules;
|
|
54
|
-
#env;
|
|
55
|
-
workerId;
|
|
56
|
-
#startAt = Date.now();
|
|
57
|
-
#app;
|
|
58
|
-
#portOffset = 0;
|
|
59
|
-
static initClient(env, workerId = parseInt(process.env.JEST_WORKER_ID ?? "0")) {
|
|
60
|
-
if (workerId === 0) throw new Error("TestClient should not be used in main thread");
|
|
61
|
-
const portOffset = workerId * 1e3 + env.appCode * 10;
|
|
62
|
-
const port = TEST_LISTEN_PORT_BASE + portOffset;
|
|
63
|
-
const endpoint = `http://localhost:${port}/backend/graphql`;
|
|
64
|
-
import_signal.client.init({
|
|
65
|
-
uri: endpoint
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
constructor(registerModules, env, workerId) {
|
|
69
|
-
this.workerId = workerId ?? parseInt(process.env.JEST_WORKER_ID ?? "0");
|
|
70
|
-
if (this.workerId === 0) throw new Error("TestServer should not be used in main thread");
|
|
71
|
-
this.#portOffset = this.workerId * 1e3 + env.appCode * 10;
|
|
72
|
-
this.#mongod = new import_mongodb_memory_server.MongoMemoryServer({
|
|
73
|
-
instance: {
|
|
74
|
-
port: TEST_MONGODB_PORT_BASE + this.#portOffset
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.#redis = new import_redis_memory_server.RedisMemoryServer({
|
|
78
|
-
instance: {
|
|
79
|
-
port: TEST_REDIS_PORT_BASE + this.#portOffset
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
this.#env = {
|
|
83
|
-
...env
|
|
84
|
-
};
|
|
85
|
-
this.#registerModules = registerModules;
|
|
86
|
-
}
|
|
87
|
-
async init() {
|
|
88
|
-
for (let i = 0; i < MAX_RETRY; i++) {
|
|
89
|
-
try {
|
|
90
|
-
const watchdog = setTimeout(() => {
|
|
91
|
-
throw new Error("TestServer Init Timeout");
|
|
92
|
-
}, MAX_ACTIVATION_TIME);
|
|
93
|
-
await this.#init();
|
|
94
|
-
clearTimeout(watchdog);
|
|
95
|
-
return;
|
|
96
|
-
} catch (e) {
|
|
97
|
-
this.#logger.error(e);
|
|
98
|
-
await this.terminate();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async #init() {
|
|
103
|
-
const now = Date.now();
|
|
104
|
-
this.#logger.log(`Test System #${this.workerId} Initializing...`);
|
|
105
|
-
const port = TEST_LISTEN_PORT_BASE + this.#portOffset;
|
|
106
|
-
const [mongoUri, redisHost, redisPort] = await Promise.all([
|
|
107
|
-
this.startMongo(),
|
|
108
|
-
this.#redis.getHost(),
|
|
109
|
-
this.#redis.getPort()
|
|
110
|
-
]);
|
|
111
|
-
this.#env.port = port;
|
|
112
|
-
this.#env.mongoUri = mongoUri;
|
|
113
|
-
this.#env.redisUri = `redis://${redisHost}:${redisPort}`;
|
|
114
|
-
this.#env.meiliUri = "http://localhost:7700/search";
|
|
115
|
-
this.#env.onCleanup = async () => {
|
|
116
|
-
await this.cleanup();
|
|
117
|
-
};
|
|
118
|
-
this.#app = await (0, import_server.createNestApp)({
|
|
119
|
-
registerModules: this.#registerModules,
|
|
120
|
-
env: this.#env
|
|
121
|
-
});
|
|
122
|
-
this.#logger.log(`Test System #${this.workerId} Initialized, Mongo: ${mongoUri}, Redis: ${redisHost}:${redisPort}`);
|
|
123
|
-
this.#startAt = Date.now();
|
|
124
|
-
this.#logger.log(`Test System #${this.workerId} Activation Time: ${this.#startAt - now}ms`);
|
|
125
|
-
}
|
|
126
|
-
async startMongo() {
|
|
127
|
-
await this.#mongod.start();
|
|
128
|
-
return this.#mongod.getUri();
|
|
129
|
-
}
|
|
130
|
-
async cleanup() {
|
|
131
|
-
const now = Date.now();
|
|
132
|
-
this.#logger.log("Mongo Memory Database Cleaning up...");
|
|
133
|
-
if (this.#mongod.state === "running") {
|
|
134
|
-
await this.#mongod.stop();
|
|
135
|
-
await this.#mongod.start(true);
|
|
136
|
-
}
|
|
137
|
-
this.#logger.log(`Mongo Memory Database Cleaned up in ${Date.now() - now}ms`);
|
|
138
|
-
}
|
|
139
|
-
async terminate() {
|
|
140
|
-
const now = Date.now();
|
|
141
|
-
const elapsed = now - this.#startAt;
|
|
142
|
-
await (0, import_common.sleep)(50);
|
|
143
|
-
import_signal.client.io?.socket.close();
|
|
144
|
-
await this.#app.close();
|
|
145
|
-
if (elapsed < MIN_ACTIVATION_TIME) {
|
|
146
|
-
this.#logger.log(`waiting for ${MIN_ACTIVATION_TIME - elapsed}`);
|
|
147
|
-
await (0, import_common.sleep)(MIN_ACTIVATION_TIME - elapsed);
|
|
148
|
-
}
|
|
149
|
-
await Promise.all([
|
|
150
|
-
import_mongoose.default.disconnect(),
|
|
151
|
-
this.#mongod.stop(),
|
|
152
|
-
this.#redis.stop()
|
|
153
|
-
]);
|
|
154
|
-
this.#logger.log(`System Terminated in ${Date.now() - now}ms`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
-
0 && (module.exports = {
|
|
159
|
-
TestServer
|
|
160
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PlaywrightTestConfig } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Read environment variables from file.
|
|
5
|
-
* https://github.com/motdotla/dotenv
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* See https://playwright.dev/docs/test-configuration.
|
|
9
|
-
*/
|
|
10
|
-
declare const withBase: (filename: string, config?: PlaywrightTestConfig) => PlaywrightTestConfig<{}, {}>;
|
|
11
|
-
|
|
12
|
-
export { withBase };
|
|
@@ -1,71 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 playwright_config_base_exports = {};
|
|
20
|
-
__export(playwright_config_base_exports, {
|
|
21
|
-
withBase: () => withBase
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(playwright_config_base_exports);
|
|
24
|
-
var import_devkit = require("@nx/devkit");
|
|
25
|
-
var import_preset = require("@nx/playwright/preset");
|
|
26
|
-
var import_test = require("@playwright/test");
|
|
27
|
-
const baseURL = process.env.BASE_URL ?? "http://127.0.0.1:4200";
|
|
28
|
-
const projectName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
|
|
29
|
-
const withBase = /* @__PURE__ */ __name((filename, config = {}) => (0, import_test.defineConfig)({
|
|
30
|
-
...(0, import_preset.nxE2EPreset)(filename, {
|
|
31
|
-
testDir: "./app"
|
|
32
|
-
}),
|
|
33
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
34
|
-
use: {
|
|
35
|
-
baseURL,
|
|
36
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
37
|
-
trace: "on-first-retry"
|
|
38
|
-
},
|
|
39
|
-
/* Run your local dev server before starting the tests */
|
|
40
|
-
webServer: {
|
|
41
|
-
command: `nx serve ${projectName}`,
|
|
42
|
-
url: "http://127.0.0.1:4200",
|
|
43
|
-
reuseExistingServer: !process.env.CI,
|
|
44
|
-
cwd: import_devkit.workspaceRoot
|
|
45
|
-
},
|
|
46
|
-
projects: [
|
|
47
|
-
{
|
|
48
|
-
name: "chromium",
|
|
49
|
-
use: {
|
|
50
|
-
...import_test.devices["Desktop Chrome"]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "firefox",
|
|
55
|
-
use: {
|
|
56
|
-
...import_test.devices["Desktop Firefox"]
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "webkit",
|
|
61
|
-
use: {
|
|
62
|
-
...import_test.devices["Desktop Safari"]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
...config
|
|
67
|
-
}), "withBase");
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {
|
|
70
|
-
withBase
|
|
71
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Page } from '@playwright/test';
|
|
2
|
-
export { expect, test } from '@playwright/test';
|
|
3
|
-
|
|
4
|
-
declare class PageAgent {
|
|
5
|
-
#private;
|
|
6
|
-
readonly page: Page;
|
|
7
|
-
constructor(page: Page);
|
|
8
|
-
goto(path: string): Promise<void>;
|
|
9
|
-
waitForPathChange(path?: string): Promise<unknown>;
|
|
10
|
-
wait(ms?: number): Promise<void>;
|
|
11
|
-
url(): string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { PageAgent };
|
|
@@ -1,74 +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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 playwright_pageAgent_exports = {};
|
|
20
|
-
__export(playwright_pageAgent_exports, {
|
|
21
|
-
PageAgent: () => PageAgent,
|
|
22
|
-
expect: () => import_test2.expect,
|
|
23
|
-
test: () => import_test.test
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(playwright_pageAgent_exports);
|
|
26
|
-
var import_test = require("@playwright/test");
|
|
27
|
-
var import_test2 = require("@playwright/test");
|
|
28
|
-
class PageAgent {
|
|
29
|
-
static {
|
|
30
|
-
__name(this, "PageAgent");
|
|
31
|
-
}
|
|
32
|
-
page;
|
|
33
|
-
#defaultWaitMs = 500;
|
|
34
|
-
#isInitialized = false;
|
|
35
|
-
constructor(page) {
|
|
36
|
-
this.page = page;
|
|
37
|
-
}
|
|
38
|
-
async goto(path) {
|
|
39
|
-
await Promise.all([
|
|
40
|
-
this.page.goto(path),
|
|
41
|
-
this.waitForPathChange(path)
|
|
42
|
-
]);
|
|
43
|
-
if (!this.#isInitialized) {
|
|
44
|
-
this.#isInitialized = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async waitForPathChange(path) {
|
|
48
|
-
return new Promise((resolve, reject) => {
|
|
49
|
-
const timeout = setTimeout(() => {
|
|
50
|
-
reject(new Error("Timeout waiting for pathChange message"));
|
|
51
|
-
}, 3e4);
|
|
52
|
-
this.page.on("console", (msg) => {
|
|
53
|
-
if (msg.type() === "log" && msg.text().startsWith(`%cpathChange-finished:${path ?? ""}`)) {
|
|
54
|
-
clearInterval(timeout);
|
|
55
|
-
setTimeout(() => {
|
|
56
|
-
resolve(true);
|
|
57
|
-
}, this.#defaultWaitMs);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async wait(ms = this.#defaultWaitMs) {
|
|
63
|
-
await this.page.waitForTimeout(ms);
|
|
64
|
-
}
|
|
65
|
-
url() {
|
|
66
|
-
return "/" + this.page.url().split("/").slice(4).join("/");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
-
0 && (module.exports = {
|
|
71
|
-
PageAgent,
|
|
72
|
-
expect,
|
|
73
|
-
test
|
|
74
|
-
});
|