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

Function setupJestGlobals

packages/jest-jasmine2/src/setup_jest_globals.ts:93–121  ·  view source on GitHub ↗
({
  config,
  globalConfig,
  localRequire,
  testPath,
}: SetupOptions)

Source from the content-addressed store, hash-verified

91};
92
93export default async function setupJestGlobals({
94 config,
95 globalConfig,
96 localRequire,
97 testPath,
98}: SetupOptions): Promise<SnapshotState> {
99 // Jest tests snapshotSerializers in order preceding built-in serializers.
100 // Therefore, add in reverse because the last added is the first tested.
101 for (let i = config.snapshotSerializers.length - 1; i >= 0; i--) {
102 addSerializer(localRequire(config.snapshotSerializers[i]));
103 }
104
105 patchJasmine();
106 const {expand, updateSnapshot} = globalConfig;
107 const {prettierPath, rootDir, snapshotFormat} = config;
108 const snapshotResolver = await buildSnapshotResolver(config, localRequire);
109 const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath);
110 const snapshotState = new SnapshotState(snapshotPath, {
111 expand,
112 prettierPath,
113 rootDir,
114 snapshotFormat,
115 updateSnapshot,
116 });
117
118 jestExpect.setState({snapshotState, testPath});
119 // Return it back to the outer scope (test runner outside the VM).
120 return snapshotState;
121}

Callers

nothing calls this directly

Calls 4

addSerializerFunction · 0.90
buildSnapshotResolverFunction · 0.90
patchJasmineFunction · 0.85
setStateMethod · 0.65

Tested by

no test coverage detected