({
config,
globalConfig,
localRequire,
testPath,
}: SetupOptions)
| 91 | }; |
| 92 | |
| 93 | export 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 | } |
nothing calls this directly
no test coverage detected