()
| 210 | } |
| 211 | |
| 212 | createFileAssert() { |
| 213 | const manager = this; |
| 214 | |
| 215 | return function fileSnapshotAssertion(actual, path, options = kEmptyObject) { |
| 216 | validateString(path, 'path'); |
| 217 | validateObject(options, 'options'); |
| 218 | const { |
| 219 | serializers = serializerFns, |
| 220 | } = options; |
| 221 | validateFunctionArray(serializers, 'options.serializers'); |
| 222 | const value = manager.serializeWithoutEscape(actual, serializers); |
| 223 | |
| 224 | if (manager.updateSnapshots) { |
| 225 | try { |
| 226 | mkdirSync(dirname(path), { __proto__: null, recursive: true }); |
| 227 | writeFileSync(path, value, 'utf8'); |
| 228 | } catch (err) { |
| 229 | throwWriteError(err, path); |
| 230 | } |
| 231 | } else { |
| 232 | let expected; |
| 233 | |
| 234 | try { |
| 235 | expected = readFileSync(path, 'utf8'); |
| 236 | } catch (err) { |
| 237 | throwReadError(err, path); |
| 238 | } |
| 239 | |
| 240 | strictEqual(value, expected); |
| 241 | } |
| 242 | }; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | function throwReadError(err, filename) { |
no test coverage detected