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

Function buildPromise

packages/jest-transform/src/__tests__/ScriptTransformer.test.ts:476–505  ·  view source on GitHub ↗
([returnValue, filePath]: [
      TransformedSource,
      string,
    ])

Source from the content-addressed store, hash-verified

474 ];
475
476 const buildPromise = async ([returnValue, filePath]: [
477 TransformedSource,
478 string,
479 ]): Promise<any> => {
480 const processorName = `passthrough-preprocessor${filePath.replaceAll(
481 /\.|\//g,
482 '-',
483 )}`;
484
485 jest.doMock(
486 processorName,
487 () => ({
488 processAsync: jest.fn(),
489 }),
490 {virtual: true},
491 );
492 const transformer = require(processorName) as AsyncTransformer;
493 jest.mocked(transformer.processAsync).mockResolvedValue(returnValue);
494
495 config = {
496 ...config,
497 transform: [...incorrectReturnValues, ...correctReturnValues].map(
498 ([_, filePath]) => [filePath, processorName, {}],
499 ),
500 };
501
502 const scriptTransformer = await createScriptTransformer(config);
503
504 return scriptTransformer.transformAsync(filePath, getCoverageOptions());
505 };
506
507 const promisesToReject = incorrectReturnValues
508 .map(buildPromise)

Callers

nothing calls this directly

Calls 7

createScriptTransformerFunction · 0.85
getCoverageOptionsFunction · 0.85
doMockMethod · 0.80
fnMethod · 0.80
mockResolvedValueMethod · 0.80
mockedMethod · 0.80
transformAsyncMethod · 0.45

Tested by

no test coverage detected