-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch(vestjs-runtime): use minifyObject for serialization
- Loading branch information
Showing
10 changed files
with
59 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,28 @@ | ||
import { assign } from 'vest-utils'; | ||
import { IsolateSerializer } from 'vestjs-runtime'; | ||
|
||
import { CommonStates } from 'CommonStateMachine'; | ||
import { TIsolateSuite } from 'IsolateSuite'; | ||
import { IsolateTestPayload } from 'IsolateTest'; | ||
import { TestStatus } from 'IsolateTestStateMachine'; | ||
import { TFieldName, TGroupName } from 'SuiteResultTypes'; | ||
import { Suite } from 'SuiteTypes'; | ||
import { VestIsolateType } from 'VestIsolateType'; | ||
import { IsolateFocusedPayload } from 'focused'; | ||
|
||
export class SuiteSerializer { | ||
static serialize(suite: Suite<TFieldName, TGroupName>) { | ||
const dump = { ...suite.dump(), output: undefined }; | ||
|
||
return IsolateSerializer.serialize(dump, MiniMap); | ||
return IsolateSerializer.serialize(dump); | ||
} | ||
|
||
static deserialize( | ||
serialized: string | TIsolateSuite | Record<string, any> | ||
serialized: string | TIsolateSuite | Record<string, any>, | ||
): TIsolateSuite { | ||
return IsolateSerializer.deserialize(serialized, MiniMap) as TIsolateSuite; | ||
return IsolateSerializer.deserialize(serialized) as TIsolateSuite; | ||
} | ||
|
||
static resume( | ||
suite: Suite<TFieldName, TGroupName>, | ||
root: string | TIsolateSuite | Record<string, any> | ||
root: string | TIsolateSuite | Record<string, any>, | ||
): void { | ||
const suiteRoot = SuiteSerializer.deserialize(root); | ||
|
||
suite.resume(suiteRoot); | ||
} | ||
} | ||
|
||
const testMiniMap: Record<keyof IsolateTestPayload, string> = { | ||
asyncTest: '_at', // asyncTest is not serialized | ||
fieldName: 'fN', | ||
groupName: 'gN', | ||
message: 'ms', | ||
severity: 'sv', | ||
status: 'st', | ||
testFn: '_tf', // testFn is not serialized | ||
}; | ||
|
||
const focusMiniMap: Record<keyof IsolateFocusedPayload, string> = { | ||
focusMode: 'fM', | ||
match: 'm', | ||
matchAll: 'mA', | ||
}; | ||
|
||
const MiniMap: MiniMap = { | ||
keys: { | ||
data: assign({}, testMiniMap, focusMiniMap), | ||
}, | ||
values: { | ||
status: { | ||
CANCELED: 'C', | ||
DONE: 'D', | ||
FAILED: 'F', | ||
INITIAL: 'I', | ||
OMITTED: 'O', | ||
PASSING: 'P', | ||
PENDING: 'PE', | ||
SKIPPED: 'S', | ||
UNTESTED: 'U', | ||
WARNING: 'W', | ||
}, | ||
$type: { | ||
Each: 'E', | ||
Focused: 'F', | ||
Group: 'G', | ||
OmitWhen: 'OW', | ||
SkipWhen: 'SW', | ||
Suite: 'S', | ||
Test: 'T', | ||
}, | ||
}, | ||
}; | ||
|
||
type MiniMap = { | ||
keys: { | ||
data: Record<keyof IsolateTestPayload, string> & | ||
Record<keyof IsolateFocusedPayload, string>; | ||
}; | ||
values: { | ||
status: Record<keyof typeof TestStatus, string> & | ||
Record<keyof typeof CommonStates, string>; | ||
$type: Record<keyof typeof VestIsolateType, string>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/vest/src/exports/__tests__/__snapshots__/SuiteSerializer.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SuiteSerializer Should produce a valid serialized dump 1`] = `"{"C":[{"D":{"fM":0,"m":["field_1"],"mA":false},"$":"F","S":"D"},{"D":{"sv":"error","fN":"field_1","ms":"field_1_message"},"$":"T","S":"F"},{"D":{"sv":"error","fN":"field_2","ms":"field_2_message"},"$":"T","S":"S"},{"C":[{"D":{"sv":"error","fN":"field_3","gN":"group_1","ms":"field_3_message_1"},"$":"T","S":"S"},{"D":{"sv":"error","fN":"field_3","gN":"group_1","ms":"field_3_message_2"},"$":"T","S":"S"},{"D":{"sv":"error","fN":"field_4","gN":"group_1","ms":"field_4_message"},"$":"T","S":"S"}],"$":"G","S":"D"},{"C":[{"D":{"sv":"error","fN":"field_5","ms":"field_5_message"},"$":"T","S":"S"}],"$":"SW","S":"D"}],"D":{"optional":{}},"$":"S","S":"D"}"`; | ||
exports[`SuiteSerializer Should produce a valid serialized dump 1`] = `"[{"0":"Suite","1":"9","2":{},"a":[{"0":"Focused","1":"9","2":{"focusMode":0,"match":["d"],"matchAll":false}},{"0":"3","1":"FAILED","2":{"4":"5","6":"d","7":"field_1_message"}},{"0":"3","1":"8","2":{"4":"5","6":"field_2","7":"field_2_message"}},{"0":"Group","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_1","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_2","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"field_4","7":"field_4_message","b":"c"}}]},{"0":"SkipWhen","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"field_5","7":"field_5_message"}}]}]},{"0":"$type","1":"status","2":"data","3":"Test","4":"severity","5":"error","6":"fieldName","7":"message","8":"SKIPPED","9":"DONE","a":"children","b":"groupName","c":"group_1","d":"field_1","e":"field_3"}]"`; |
Oops, something went wrong.
d664f5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
vest-next – ./website
vest-next-git-latest-ealush.vercel.app
vest-website.vercel.app
vest-next.vercel.app
vest-next-ealush.vercel.app
d664f5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
vest – ./website
vest.vercel.app
www.vestjs.dev
vest-git-latest-ealush.vercel.app
vest-ealush.vercel.app
vestjs.dev