MCPcopy
hub / github.com/jestjs/jest / reportSuccess

Function reportSuccess

packages/jest-worker/src/workers/processChild.ts:96–116  ·  view source on GitHub ↗
(result: unknown)

Source from the content-addressed store, hash-verified

94process.on('message', messageListener);
95
96function reportSuccess(result: unknown) {
97 if (!process || !process.send) {
98 throw new Error('Child can only be used on a forked process');
99 }
100
101 try {
102 process.send([PARENT_MESSAGE_OK, result]);
103 } catch (error) {
104 if (
105 isError(error) &&
106 // if .send is a function, it's a serialization issue
107 !error.message.includes('.send is not a function')
108 ) {
109 // Apply specific serialization only in error cases
110 // to avoid affecting performance in regular cases.
111 process.send([PARENT_MESSAGE_OK, packMessage(result)]);
112 } else {
113 throw error;
114 }
115 }
116}
117
118function reportClientError(error: Error) {
119 return reportError(error, PARENT_MESSAGE_CLIENT_ERROR);

Callers 1

messageListenerFunction · 0.70

Calls 3

packMessageFunction · 0.90
sendMethod · 0.65
isErrorFunction · 0.50

Tested by

no test coverage detected