polfan-server-js-client 0.3.3 → 0.4.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/.gitmodules +3 -3
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]/shelved.patch +447 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28__Changes_.xml +4 -0
- package/.idea/workspace.xml +193 -6
- package/CODE_OF_CONDUCT.md +76 -76
- package/README.md +44 -44
- package/babel.config.js +5 -5
- package/build/index.cjs.js +392 -429
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +4 -15
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +0 -48
- package/build/types/types/src/index.d.ts +3 -3
- package/build/types/types/src/schemes/SessionData.d.ts +6 -0
- package/build/types/types/src/schemes/User.d.ts +15 -0
- package/build/types/types/src/schemes/UserData.d.ts +5 -0
- package/build/types/types/src/schemes/commands/SetSessionData.d.ts +9 -1
- package/build/types/types/src/schemes/commands/SetUserData.d.ts +1 -0
- package/jest.config.ts +199 -199
- package/package.json +43 -43
- package/scripts/getPackageJson.js +24 -24
- package/src/FilesClient.ts +42 -42
- package/src/index.ts +31 -29
- package/src/state-tracker/ChatStateTracker.ts +71 -71
- package/src/state-tracker/RoomMessagesHistory.ts +9 -27
- package/src/state-tracker/TopicHistoryWindow.ts +1 -133
- package/src/state-tracker/UsersManager.ts +51 -51
- package/src/state-tracker/functions.ts +28 -28
- package/src/types/src/index.ts +313 -311
- package/src/types/src/schemes/SessionData.ts +8 -1
- package/src/types/src/schemes/User.ts +17 -1
- package/src/types/src/schemes/UserData.ts +5 -0
- package/src/types/src/schemes/commands/SetSessionData.ts +11 -2
- package/src/types/src/schemes/commands/SetUserData.ts +1 -0
- package/tests/async-utils.test.ts +29 -29
- package/tests/history-window.test.ts +0 -131
- package/tests/space-roles.test.ts +42 -42
- package/tests/state-reconnect.test.ts +0 -260
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26_[Changes]/shelved.patch +0 -174
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26__Changes_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_rebase_[Changes]/shelved.patch +0 -18
- package/.idea/shelf/Uncommitted_changes_before_rebase__Changes_.xml +0 -4
package/build/types/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import { IndexedCollection, IndexedObjectCollection, ObservableIndexedCollection
|
|
|
4
4
|
import { FilesClient, File } from "./FilesClient";
|
|
5
5
|
import { Permissions, PermissionDefinition, Layer } from "./Permissions";
|
|
6
6
|
import * as ChatTypes from './types/src';
|
|
7
|
+
import { UserStatus } from './types/src';
|
|
7
8
|
import { extractUserFromMember } from "./state-tracker/functions";
|
|
8
9
|
import { AbstractRestClient } from "./AbstractRestClient";
|
|
9
10
|
import { UnreadSummary } from "./state-tracker/FollowedTopicsManager";
|
|
10
|
-
export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, };
|
|
11
|
+
export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, UserStatus, };
|
|
11
12
|
export type { ChatTypes, File, UnreadSummary, };
|
|
@@ -6,7 +6,6 @@ export declare class RoomMessagesHistory {
|
|
|
6
6
|
private tracker;
|
|
7
7
|
private historyWindows;
|
|
8
8
|
private traverseLock;
|
|
9
|
-
private timeLimitedHistory;
|
|
10
9
|
constructor(room: Room, tracker: ChatStateTracker);
|
|
11
10
|
/**
|
|
12
11
|
* Returns a history window object for the given topic ID, allowing you to view message history.
|
|
@@ -21,24 +20,14 @@ export declare class RoomMessagesHistory {
|
|
|
21
20
|
*
|
|
22
21
|
* The window bindings are preserved; only windows that the application had
|
|
23
22
|
* actually pulled to the latest page (state === LATEST) are refreshed, with
|
|
24
|
-
* a single
|
|
25
|
-
* were never pulled (LIVE) or belong to an ephemeral room are left
|
|
26
|
-
* so their in-memory context survives the reconnect.
|
|
27
|
-
*
|
|
28
|
-
* How a refreshed window is rebuilt depends on the room history mode: rooms
|
|
29
|
-
* keeping the full history are simply reset to the latest page (it can
|
|
30
|
-
* always be traversed back on demand), while rooms with a time-limited
|
|
31
|
-
* history (MaxAge) load the messages missed during the downtime on top of
|
|
32
|
-
* the already loaded ones, with the messages returned in both deduplicated.
|
|
33
|
-
* The maxAge retention applies to what the server serves - so that users
|
|
34
|
-
* joining later do not see the older conversation - and never to what this
|
|
35
|
-
* client already has: messages the user witnessed stay in the window until
|
|
36
|
-
* they are pushed out by its own size limit.
|
|
23
|
+
* a single resetToLatest instead of a chain of catch-up requests. Windows
|
|
24
|
+
* that were never pulled (LIVE) or belong to an ephemeral room are left
|
|
25
|
+
* untouched so their in-memory context survives the reconnect.
|
|
37
26
|
*/
|
|
38
27
|
resync(room: Room): Promise<void>;
|
|
39
28
|
private handleRoomUpdated;
|
|
40
29
|
private handleNewTopic;
|
|
41
30
|
private handleTopicDeleted;
|
|
42
31
|
private createHistoryWindowForTopic;
|
|
43
|
-
private
|
|
32
|
+
private updateTraverseLock;
|
|
44
33
|
}
|
|
@@ -34,7 +34,6 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
|
|
|
34
34
|
fetchLimit: number;
|
|
35
35
|
lastFetchCount: number;
|
|
36
36
|
oldestId: string | null;
|
|
37
|
-
gaps: string[];
|
|
38
37
|
};
|
|
39
38
|
/**
|
|
40
39
|
* Number of items to fetch per request.
|
|
@@ -63,44 +62,12 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
|
|
|
63
62
|
*/
|
|
64
63
|
set retainRatio(value: number);
|
|
65
64
|
get hasLatest(): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* IDs of the items the window could not stitch to the ones loaded before
|
|
68
|
-
* them: there is a gap in front of each of them, i.e. the item right above
|
|
69
|
-
* it in the window is not its real predecessor and an unknown number of
|
|
70
|
-
* items in between was never fetched.
|
|
71
|
-
*
|
|
72
|
-
* Such a gap appears when the collection is resynchronised after a
|
|
73
|
-
* reconnect (see resyncToLatest) and more items than a single page arrived
|
|
74
|
-
* while the connection was down. The markers are kept in the window order
|
|
75
|
-
* and disappear together with the items they point at.
|
|
76
|
-
*/
|
|
77
|
-
get gaps(): readonly string[];
|
|
78
65
|
get hasOldest(): boolean;
|
|
79
66
|
abstract createMirror(): TraversableRemoteCollection<ItemT, EventMapT>;
|
|
80
67
|
resetToLatest(force?: boolean): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Refresh the window with the latest page, keeping the already loaded items
|
|
83
|
-
* instead of replacing them.
|
|
84
|
-
*
|
|
85
|
-
* This is the reconnect-friendly variant of resetToLatest: the items missed
|
|
86
|
-
* while the connection was down are pulled with a single request and merged
|
|
87
|
-
* on top of the loaded ones (items returned in both are deduplicated), so
|
|
88
|
-
* the context the application already had does not disappear. The window
|
|
89
|
-
* size limit is the only thing that pushes the oldest items out.
|
|
90
|
-
*
|
|
91
|
-
* An empty or partial page is not a reason to drop anything: it only means
|
|
92
|
-
* the collection has little (or nothing) left on the remote side, while the
|
|
93
|
-
* items loaded earlier are still valid. When the page is full and does not
|
|
94
|
-
* reach the loaded items, an unknown number of items in between was never
|
|
95
|
-
* fetched - both parts are still kept, and the seam between them is recorded
|
|
96
|
-
* in `gaps` so the application can show where the history is not continuous.
|
|
97
|
-
*/
|
|
98
|
-
resyncToLatest(): Promise<void>;
|
|
99
68
|
fetchPrevious(): Promise<void>;
|
|
100
69
|
fetchNext(): Promise<void>;
|
|
101
70
|
jumpTo(id: string): Promise<void>;
|
|
102
|
-
delete(...ids: string[]): void;
|
|
103
|
-
deleteAll(): void;
|
|
104
71
|
protected abstract fetchLatestItems(): Promise<ItemT[]>;
|
|
105
72
|
protected abstract fetchItemsBefore(): Promise<ItemT[] | null>;
|
|
106
73
|
protected abstract fetchItemsAfter(): Promise<ItemT[] | null>;
|
|
@@ -109,20 +76,6 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
|
|
|
109
76
|
protected refreshFetchedState(): Promise<void>;
|
|
110
77
|
protected addItems(newItems: ItemT[], to: 'head' | 'tail'): void;
|
|
111
78
|
protected emitChangeWithDiff(itemChanged: boolean, originalState: WindowState): void;
|
|
112
|
-
/**
|
|
113
|
-
* Record that the history is not continuous in front of the given item.
|
|
114
|
-
*/
|
|
115
|
-
protected markGapBefore(id: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* Forget the gap in front of the given item - the items before it are known
|
|
118
|
-
* to be its real predecessors now.
|
|
119
|
-
*/
|
|
120
|
-
protected clearGapBefore(id: string): void;
|
|
121
|
-
/**
|
|
122
|
-
* Forget the gap markers pointing at items that are no longer in the window
|
|
123
|
-
* (trimmed, deleted or replaced), so `gaps` never refers to nothing.
|
|
124
|
-
*/
|
|
125
|
-
protected dropDanglingGaps(): void;
|
|
126
79
|
/**
|
|
127
80
|
* Return array with messages trimmed using High/Low Watermark strategy.
|
|
128
81
|
*/
|
|
@@ -147,7 +100,6 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
147
100
|
get isTraverseLocked(): boolean;
|
|
148
101
|
setTraverseLock(lock: boolean): Promise<void>;
|
|
149
102
|
resetToLatest(force?: boolean): Promise<void>;
|
|
150
|
-
resyncToLatest(): Promise<void>;
|
|
151
103
|
fetchNext(): Promise<void>;
|
|
152
104
|
fetchPrevious(): Promise<void>;
|
|
153
105
|
jumpTo(id: string): Promise<void>;
|
|
@@ -8,7 +8,7 @@ import { RoomSummary, RoomSummaryExtras } from "./schemes/RoomSummary";
|
|
|
8
8
|
import { Space, SpaceDiscoverable } from "./schemes/Space";
|
|
9
9
|
import { SpaceMember } from "./schemes/SpaceMember";
|
|
10
10
|
import { Topic } from "./schemes/Topic";
|
|
11
|
-
import { User } from "./schemes/User";
|
|
11
|
+
import { User, UserStatus } from "./schemes/User";
|
|
12
12
|
import { UserState } from "./schemes/UserState";
|
|
13
13
|
import { Bye } from "./schemes/events/Bye";
|
|
14
14
|
import { Error } from "./schemes/events/Error";
|
|
@@ -134,7 +134,7 @@ import { GetUserInfo } from "./schemes/commands/GetUserInfo";
|
|
|
134
134
|
import { UserInfo } from "./schemes/events/UserInfo";
|
|
135
135
|
import { UserInformation } from "./schemes/UserInformation";
|
|
136
136
|
import { SetSessionData, SessionPush } from "./schemes/commands/SetSessionData";
|
|
137
|
-
import { SessionData } from "./schemes/SessionData";
|
|
137
|
+
import { SessionData, SessionPlatform } from "./schemes/SessionData";
|
|
138
138
|
import { GetSessionData } from "./schemes/commands/GetSessionData";
|
|
139
139
|
import { UserData, PrivateMessagePolicy } from "./schemes/UserData";
|
|
140
140
|
import { SetUserData } from "./schemes/commands/SetUserData";
|
|
@@ -145,4 +145,4 @@ import { Uninvite } from "./schemes/commands/Uninvite";
|
|
|
145
145
|
import { GetInvited } from "./schemes/commands/GetInvited";
|
|
146
146
|
import { Invited } from "./schemes/events/Invited";
|
|
147
147
|
import { TopicUnfollowed } from "./schemes/events/TopicUnfollowed";
|
|
148
|
-
export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, UserData, PrivateMessagePolicy, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, RoomMemberLeft, RoomMembers, RoomMemberUpdated, UserUpdated, Session, SpaceDeleted, SpaceUpdated, SpaceJoined, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMembers, SpaceMemberUpdated, SpaceRooms, TopicDeleted, TopicUpdated, PermissionOverwriteTargets, Owners, Ok, DiscoverableSpaces, Emoticons, EmoticonDeleted, NewEmoticon, Bans, ClientData, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, GetFollowedTopics, DeassignRole, DeleteRole, DeleteRoom, DeleteSpace, DeleteTopic, SetPermissionOverwrites, GetPermissionOverwrites, GetComputedPermissions, GetRoomMembers, GetSession, GetSpaceMembers, GetSpaceRooms, JoinRoom, JoinSpace, LeaveRoom, LeaveSpace, UpdateRole, UpdateSpace, UpdateRoom, UpdateTopic, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, Topics, GetTopics, GetDiscoverableSpaces, GetEmoticons, CreateEmoticon, DeleteEmoticon, Ban, Unban, GetBans, Kick, GetClientData, SetClientData, GetSpaceSummary, GetRoomSummary, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, };
|
|
148
|
+
export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserStatus, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, SessionPlatform, UserData, PrivateMessagePolicy, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, RoomMemberLeft, RoomMembers, RoomMemberUpdated, UserUpdated, Session, SpaceDeleted, SpaceUpdated, SpaceJoined, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMembers, SpaceMemberUpdated, SpaceRooms, TopicDeleted, TopicUpdated, PermissionOverwriteTargets, Owners, Ok, DiscoverableSpaces, Emoticons, EmoticonDeleted, NewEmoticon, Bans, ClientData, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, GetFollowedTopics, DeassignRole, DeleteRole, DeleteRoom, DeleteSpace, DeleteTopic, SetPermissionOverwrites, GetPermissionOverwrites, GetComputedPermissions, GetRoomMembers, GetSession, GetSpaceMembers, GetSpaceRooms, JoinRoom, JoinSpace, LeaveRoom, LeaveSpace, UpdateRole, UpdateSpace, UpdateRoom, UpdateTopic, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, Topics, GetTopics, GetDiscoverableSpaces, GetEmoticons, CreateEmoticon, DeleteEmoticon, Ban, Unban, GetBans, Kick, GetClientData, SetClientData, GetSpaceSummary, GetRoomSummary, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { SessionPush } from "./commands/SetSessionData";
|
|
2
|
+
/**
|
|
3
|
+
* Platform of a client session. Reported on connect (the `platform` query
|
|
4
|
+
* parameter) and independent of the push registration.
|
|
5
|
+
*/
|
|
6
|
+
export type SessionPlatform = 'web' | 'ios' | 'android' | 'desktop';
|
|
2
7
|
export interface SessionData {
|
|
8
|
+
platform?: SessionPlatform;
|
|
3
9
|
push?: SessionPush;
|
|
4
10
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
export type UserTags = 'bot' | 'temp' | string;
|
|
2
|
+
/**
|
|
3
|
+
* Availability of a user, aggregated over all of their sessions.
|
|
4
|
+
*
|
|
5
|
+
* - `Offline` - no session is connected and none can be reached asynchronously.
|
|
6
|
+
* - `Online` - at least one session holds a live connection.
|
|
7
|
+
* - `OnlineAsync` - no live connection, but a push-registered device was active
|
|
8
|
+
* recently, so a message will still reach the user.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum UserStatus {
|
|
11
|
+
Offline = 0,
|
|
12
|
+
Online = 1,
|
|
13
|
+
OnlineAsync = 2
|
|
14
|
+
}
|
|
2
15
|
export interface User {
|
|
3
16
|
id: string;
|
|
4
17
|
nick: string;
|
|
5
18
|
avatar: string;
|
|
6
19
|
tags: UserTags[];
|
|
20
|
+
status: UserStatus;
|
|
21
|
+
/** @deprecated Use {@link status}. Kept for clients older than the numeric status. */
|
|
7
22
|
online: boolean;
|
|
8
23
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export type PrivateMessagePolicy = 'None' | 'Mutual' | 'All';
|
|
2
2
|
export interface UserData {
|
|
3
3
|
privateMessagePolicy: PrivateMessagePolicy;
|
|
4
|
+
/**
|
|
5
|
+
* Whether others may see that the user is reachable on a push-registered
|
|
6
|
+
* device while disconnected. When false the user simply reads as offline.
|
|
7
|
+
*/
|
|
8
|
+
showAsyncPresence: boolean;
|
|
4
9
|
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { SessionPlatform } from "../SessionData";
|
|
1
2
|
export interface SessionPush {
|
|
2
3
|
token?: string;
|
|
3
|
-
platform?: 'ios' | 'android' | 'web';
|
|
4
4
|
active?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated The platform describes the session, not its push registration.
|
|
7
|
+
* Use {@link SetSessionData.platform} (or the `platform` connection query
|
|
8
|
+
* parameter). Still accepted by the server, but the top-level field wins.
|
|
9
|
+
*/
|
|
10
|
+
platform?: SessionPlatform;
|
|
5
11
|
}
|
|
6
12
|
export interface SetSessionData {
|
|
7
13
|
clientFocused?: boolean;
|
|
8
14
|
push?: SessionPush;
|
|
15
|
+
/** Client platform of this session; null leaves the stored value unchanged. */
|
|
16
|
+
platform?: SessionPlatform;
|
|
9
17
|
}
|
package/jest.config.ts
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
-
* https://jestjs.io/docs/configuration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {Config} from 'jest';
|
|
7
|
-
|
|
8
|
-
const config: Config = {
|
|
9
|
-
// All imported modules in your tests should be mocked automatically
|
|
10
|
-
// automock: false,
|
|
11
|
-
|
|
12
|
-
// Stop running tests after `n` failures
|
|
13
|
-
// bail: 0,
|
|
14
|
-
|
|
15
|
-
// The directory where Jest should store its cached dependency information
|
|
16
|
-
// cacheDirectory: "C:\\Users\\Szado\\AppData\\Local\\Temp\\jest",
|
|
17
|
-
|
|
18
|
-
// Automatically clear mock calls, instances, contexts and results before every test
|
|
19
|
-
clearMocks: true,
|
|
20
|
-
|
|
21
|
-
// Indicates whether the coverage information should be collected while executing the test
|
|
22
|
-
collectCoverage: false,
|
|
23
|
-
|
|
24
|
-
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
25
|
-
// collectCoverageFrom: undefined,
|
|
26
|
-
|
|
27
|
-
// The directory where Jest should output its coverage files
|
|
28
|
-
coverageDirectory: "coverage",
|
|
29
|
-
|
|
30
|
-
// An array of regexp pattern strings used to skip coverage collection
|
|
31
|
-
// coveragePathIgnorePatterns: [
|
|
32
|
-
// "\\\\node_modules\\\\"
|
|
33
|
-
// ],
|
|
34
|
-
|
|
35
|
-
// Indicates which provider should be used to instrument code for coverage
|
|
36
|
-
coverageProvider: "v8",
|
|
37
|
-
|
|
38
|
-
// A list of reporter names that Jest uses when writing coverage reports
|
|
39
|
-
// coverageReporters: [
|
|
40
|
-
// "json",
|
|
41
|
-
// "text",
|
|
42
|
-
// "lcov",
|
|
43
|
-
// "clover"
|
|
44
|
-
// ],
|
|
45
|
-
|
|
46
|
-
// An object that configures minimum threshold enforcement for coverage results
|
|
47
|
-
// coverageThreshold: undefined,
|
|
48
|
-
|
|
49
|
-
// A path to a custom dependency extractor
|
|
50
|
-
// dependencyExtractor: undefined,
|
|
51
|
-
|
|
52
|
-
// Make calling deprecated APIs throw helpful error messages
|
|
53
|
-
// errorOnDeprecated: false,
|
|
54
|
-
|
|
55
|
-
// The default configuration for fake timers
|
|
56
|
-
// fakeTimers: {
|
|
57
|
-
// "enableGlobally": false
|
|
58
|
-
// },
|
|
59
|
-
|
|
60
|
-
// Force coverage collection from ignored files using an array of glob patterns
|
|
61
|
-
// forceCoverageMatch: [],
|
|
62
|
-
|
|
63
|
-
// A path to a module which exports an async function that is triggered once before all test suites
|
|
64
|
-
// globalSetup: undefined,
|
|
65
|
-
|
|
66
|
-
// A path to a module which exports an async function that is triggered once after all test suites
|
|
67
|
-
// globalTeardown: undefined,
|
|
68
|
-
|
|
69
|
-
// A set of global variables that need to be available in all test environments
|
|
70
|
-
// globals: {},
|
|
71
|
-
|
|
72
|
-
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
73
|
-
// maxWorkers: "50%",
|
|
74
|
-
|
|
75
|
-
// An array of directory names to be searched recursively up from the requiring module's location
|
|
76
|
-
// moduleDirectories: [
|
|
77
|
-
// "node_modules"
|
|
78
|
-
// ],
|
|
79
|
-
|
|
80
|
-
// An array of file extensions your modules use
|
|
81
|
-
// moduleFileExtensions: [
|
|
82
|
-
// "js",
|
|
83
|
-
// "mjs",
|
|
84
|
-
// "cjs",
|
|
85
|
-
// "jsx",
|
|
86
|
-
// "ts",
|
|
87
|
-
// "tsx",
|
|
88
|
-
// "json",
|
|
89
|
-
// "node"
|
|
90
|
-
// ],
|
|
91
|
-
|
|
92
|
-
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
93
|
-
// moduleNameMapper: {},
|
|
94
|
-
|
|
95
|
-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
96
|
-
// modulePathIgnorePatterns: [],
|
|
97
|
-
|
|
98
|
-
// Activates notifications for test results
|
|
99
|
-
// notify: false,
|
|
100
|
-
|
|
101
|
-
// An enum that specifies notification mode. Requires { notify: true }
|
|
102
|
-
// notifyMode: "failure-change",
|
|
103
|
-
|
|
104
|
-
// A preset that is used as a base for Jest's configuration
|
|
105
|
-
// preset: undefined,
|
|
106
|
-
|
|
107
|
-
// Run tests from one or more projects
|
|
108
|
-
// projects: undefined,
|
|
109
|
-
|
|
110
|
-
// Use this configuration option to add custom reporters to Jest
|
|
111
|
-
// reporters: undefined,
|
|
112
|
-
|
|
113
|
-
// Automatically reset mock state before every test
|
|
114
|
-
// resetMocks: false,
|
|
115
|
-
|
|
116
|
-
// Reset the module registry before running each individual test
|
|
117
|
-
// resetModules: false,
|
|
118
|
-
|
|
119
|
-
// A path to a custom resolver
|
|
120
|
-
// resolver: undefined,
|
|
121
|
-
|
|
122
|
-
// Automatically restore mock state and implementation before every test
|
|
123
|
-
// restoreMocks: false,
|
|
124
|
-
|
|
125
|
-
// The root directory that Jest should scan for tests and modules within
|
|
126
|
-
// rootDir: undefined,
|
|
127
|
-
|
|
128
|
-
// A list of paths to directories that Jest should use to search for files in
|
|
129
|
-
// roots: [
|
|
130
|
-
// "<rootDir>"
|
|
131
|
-
// ],
|
|
132
|
-
|
|
133
|
-
// Allows you to use a custom runner instead of Jest's default test runner
|
|
134
|
-
// runner: "jest-runner",
|
|
135
|
-
|
|
136
|
-
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
137
|
-
// setupFiles: [],
|
|
138
|
-
|
|
139
|
-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
140
|
-
// setupFilesAfterEnv: [],
|
|
141
|
-
|
|
142
|
-
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
143
|
-
// slowTestThreshold: 5,
|
|
144
|
-
|
|
145
|
-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
146
|
-
// snapshotSerializers: [],
|
|
147
|
-
|
|
148
|
-
// The test environment that will be used for testing
|
|
149
|
-
// testEnvironment: "jest-environment-node",
|
|
150
|
-
|
|
151
|
-
// Options that will be passed to the testEnvironment
|
|
152
|
-
// testEnvironmentOptions: {},
|
|
153
|
-
|
|
154
|
-
// Adds a location field to test results
|
|
155
|
-
// testLocationInResults: false,
|
|
156
|
-
|
|
157
|
-
// The glob patterns Jest uses to detect test files
|
|
158
|
-
// testMatch: [
|
|
159
|
-
// "**/__tests__/**/*.[jt]s?(x)",
|
|
160
|
-
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
161
|
-
// ],
|
|
162
|
-
|
|
163
|
-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
164
|
-
// testPathIgnorePatterns: [
|
|
165
|
-
// "\\\\node_modules\\\\"
|
|
166
|
-
// ],
|
|
167
|
-
|
|
168
|
-
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
169
|
-
// testRegex: [],
|
|
170
|
-
|
|
171
|
-
// This option allows the use of a custom results processor
|
|
172
|
-
// testResultsProcessor: undefined,
|
|
173
|
-
|
|
174
|
-
// This option allows use of a custom test runner
|
|
175
|
-
// testRunner: "jest-circus/runner",
|
|
176
|
-
|
|
177
|
-
// A map from regular expressions to paths to transformers
|
|
178
|
-
// transform: undefined,
|
|
179
|
-
|
|
180
|
-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
181
|
-
// transformIgnorePatterns: [
|
|
182
|
-
// "\\\\node_modules\\\\",
|
|
183
|
-
// "\\.pnp\\.[^\\\\]+$"
|
|
184
|
-
// ],
|
|
185
|
-
|
|
186
|
-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
187
|
-
// unmockedModulePathPatterns: undefined,
|
|
188
|
-
|
|
189
|
-
// Indicates whether each individual test should be reported during the run
|
|
190
|
-
// verbose: undefined,
|
|
191
|
-
|
|
192
|
-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
193
|
-
// watchPathIgnorePatterns: [],
|
|
194
|
-
|
|
195
|
-
// Whether to use watchman for file crawling
|
|
196
|
-
// watchman: true,
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export default config;
|
|
1
|
+
/**
|
|
2
|
+
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
+
* https://jestjs.io/docs/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {Config} from 'jest';
|
|
7
|
+
|
|
8
|
+
const config: Config = {
|
|
9
|
+
// All imported modules in your tests should be mocked automatically
|
|
10
|
+
// automock: false,
|
|
11
|
+
|
|
12
|
+
// Stop running tests after `n` failures
|
|
13
|
+
// bail: 0,
|
|
14
|
+
|
|
15
|
+
// The directory where Jest should store its cached dependency information
|
|
16
|
+
// cacheDirectory: "C:\\Users\\Szado\\AppData\\Local\\Temp\\jest",
|
|
17
|
+
|
|
18
|
+
// Automatically clear mock calls, instances, contexts and results before every test
|
|
19
|
+
clearMocks: true,
|
|
20
|
+
|
|
21
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
22
|
+
collectCoverage: false,
|
|
23
|
+
|
|
24
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
25
|
+
// collectCoverageFrom: undefined,
|
|
26
|
+
|
|
27
|
+
// The directory where Jest should output its coverage files
|
|
28
|
+
coverageDirectory: "coverage",
|
|
29
|
+
|
|
30
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
31
|
+
// coveragePathIgnorePatterns: [
|
|
32
|
+
// "\\\\node_modules\\\\"
|
|
33
|
+
// ],
|
|
34
|
+
|
|
35
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
36
|
+
coverageProvider: "v8",
|
|
37
|
+
|
|
38
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
39
|
+
// coverageReporters: [
|
|
40
|
+
// "json",
|
|
41
|
+
// "text",
|
|
42
|
+
// "lcov",
|
|
43
|
+
// "clover"
|
|
44
|
+
// ],
|
|
45
|
+
|
|
46
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
47
|
+
// coverageThreshold: undefined,
|
|
48
|
+
|
|
49
|
+
// A path to a custom dependency extractor
|
|
50
|
+
// dependencyExtractor: undefined,
|
|
51
|
+
|
|
52
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
53
|
+
// errorOnDeprecated: false,
|
|
54
|
+
|
|
55
|
+
// The default configuration for fake timers
|
|
56
|
+
// fakeTimers: {
|
|
57
|
+
// "enableGlobally": false
|
|
58
|
+
// },
|
|
59
|
+
|
|
60
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
61
|
+
// forceCoverageMatch: [],
|
|
62
|
+
|
|
63
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
64
|
+
// globalSetup: undefined,
|
|
65
|
+
|
|
66
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
67
|
+
// globalTeardown: undefined,
|
|
68
|
+
|
|
69
|
+
// A set of global variables that need to be available in all test environments
|
|
70
|
+
// globals: {},
|
|
71
|
+
|
|
72
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
73
|
+
// maxWorkers: "50%",
|
|
74
|
+
|
|
75
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
76
|
+
// moduleDirectories: [
|
|
77
|
+
// "node_modules"
|
|
78
|
+
// ],
|
|
79
|
+
|
|
80
|
+
// An array of file extensions your modules use
|
|
81
|
+
// moduleFileExtensions: [
|
|
82
|
+
// "js",
|
|
83
|
+
// "mjs",
|
|
84
|
+
// "cjs",
|
|
85
|
+
// "jsx",
|
|
86
|
+
// "ts",
|
|
87
|
+
// "tsx",
|
|
88
|
+
// "json",
|
|
89
|
+
// "node"
|
|
90
|
+
// ],
|
|
91
|
+
|
|
92
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
93
|
+
// moduleNameMapper: {},
|
|
94
|
+
|
|
95
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
96
|
+
// modulePathIgnorePatterns: [],
|
|
97
|
+
|
|
98
|
+
// Activates notifications for test results
|
|
99
|
+
// notify: false,
|
|
100
|
+
|
|
101
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
102
|
+
// notifyMode: "failure-change",
|
|
103
|
+
|
|
104
|
+
// A preset that is used as a base for Jest's configuration
|
|
105
|
+
// preset: undefined,
|
|
106
|
+
|
|
107
|
+
// Run tests from one or more projects
|
|
108
|
+
// projects: undefined,
|
|
109
|
+
|
|
110
|
+
// Use this configuration option to add custom reporters to Jest
|
|
111
|
+
// reporters: undefined,
|
|
112
|
+
|
|
113
|
+
// Automatically reset mock state before every test
|
|
114
|
+
// resetMocks: false,
|
|
115
|
+
|
|
116
|
+
// Reset the module registry before running each individual test
|
|
117
|
+
// resetModules: false,
|
|
118
|
+
|
|
119
|
+
// A path to a custom resolver
|
|
120
|
+
// resolver: undefined,
|
|
121
|
+
|
|
122
|
+
// Automatically restore mock state and implementation before every test
|
|
123
|
+
// restoreMocks: false,
|
|
124
|
+
|
|
125
|
+
// The root directory that Jest should scan for tests and modules within
|
|
126
|
+
// rootDir: undefined,
|
|
127
|
+
|
|
128
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
129
|
+
// roots: [
|
|
130
|
+
// "<rootDir>"
|
|
131
|
+
// ],
|
|
132
|
+
|
|
133
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
134
|
+
// runner: "jest-runner",
|
|
135
|
+
|
|
136
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
137
|
+
// setupFiles: [],
|
|
138
|
+
|
|
139
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
140
|
+
// setupFilesAfterEnv: [],
|
|
141
|
+
|
|
142
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
143
|
+
// slowTestThreshold: 5,
|
|
144
|
+
|
|
145
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
146
|
+
// snapshotSerializers: [],
|
|
147
|
+
|
|
148
|
+
// The test environment that will be used for testing
|
|
149
|
+
// testEnvironment: "jest-environment-node",
|
|
150
|
+
|
|
151
|
+
// Options that will be passed to the testEnvironment
|
|
152
|
+
// testEnvironmentOptions: {},
|
|
153
|
+
|
|
154
|
+
// Adds a location field to test results
|
|
155
|
+
// testLocationInResults: false,
|
|
156
|
+
|
|
157
|
+
// The glob patterns Jest uses to detect test files
|
|
158
|
+
// testMatch: [
|
|
159
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
160
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
161
|
+
// ],
|
|
162
|
+
|
|
163
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
164
|
+
// testPathIgnorePatterns: [
|
|
165
|
+
// "\\\\node_modules\\\\"
|
|
166
|
+
// ],
|
|
167
|
+
|
|
168
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
169
|
+
// testRegex: [],
|
|
170
|
+
|
|
171
|
+
// This option allows the use of a custom results processor
|
|
172
|
+
// testResultsProcessor: undefined,
|
|
173
|
+
|
|
174
|
+
// This option allows use of a custom test runner
|
|
175
|
+
// testRunner: "jest-circus/runner",
|
|
176
|
+
|
|
177
|
+
// A map from regular expressions to paths to transformers
|
|
178
|
+
// transform: undefined,
|
|
179
|
+
|
|
180
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
181
|
+
// transformIgnorePatterns: [
|
|
182
|
+
// "\\\\node_modules\\\\",
|
|
183
|
+
// "\\.pnp\\.[^\\\\]+$"
|
|
184
|
+
// ],
|
|
185
|
+
|
|
186
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
187
|
+
// unmockedModulePathPatterns: undefined,
|
|
188
|
+
|
|
189
|
+
// Indicates whether each individual test should be reported during the run
|
|
190
|
+
// verbose: undefined,
|
|
191
|
+
|
|
192
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
193
|
+
// watchPathIgnorePatterns: [],
|
|
194
|
+
|
|
195
|
+
// Whether to use watchman for file crawling
|
|
196
|
+
// watchman: true,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default config;
|