MCPcopy
hub / github.com/apify/crawlee / exitHandler

Function exitHandler

test/e2e/run.mjs:106–134  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

104 });
105
106 const exitHandler = async (code) => {
107 if (code === SKIPPED_TEST_CLOSE_CODE) {
108 console.log(`${prefix}${colors.grey('Test skipped')}`);
109 return;
110 }
111
112 if (code !== 0) {
113 for (const line of deferredOnSuccess) console.log(`${prefix}${line}`);
114 }
115
116 const took = (Date.now() - now) / 1000;
117 const status = code === 0 ? 'success' : 'failure';
118 const color = code === 0 ? 'green' : 'red';
119 console.log(
120 `${colors.yellow(`[${dir.name}] `)}${colors[color](
121 `Test finished with status: ${status} `,
122 )}${colors.grey(`[took ${took}s]`)}`,
123 );
124
125 if (['MEMORY', 'LOCAL'].includes(process.env.STORAGE_IMPLEMENTATION)) {
126 await clearStorage(`${basePath}/${dir.name}`);
127 }
128
129 if (process.env.STORAGE_IMPLEMENTATION === 'PLATFORM') {
130 await clearPackages(`${basePath}/${dir.name}`);
131 }
132
133 if (status === 'failure') failure = true;
134 };
135
136 const { promise: waitForExit, resolve: markTestDone } = Promise.withResolvers();
137

Callers 1

runFunction · 0.85

Calls 3

clearStorageFunction · 0.90
clearPackagesFunction · 0.90
logMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…