MCPcopy Index your code
hub / github.com/nodejs/node / createAssert

Method createAssert

lib/internal/test_runner/snapshot.js:189–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187 }
188
189 createAssert() {
190 const manager = this;
191
192 return function snapshotAssertion(actual, options = kEmptyObject) {
193 validateObject(options, 'options');
194 const {
195 serializers = serializerFns,
196 } = options;
197 validateFunctionArray(serializers, 'options.serializers');
198 const { filePath, fullName } = this;
199 const snapshotFile = manager.resolveSnapshotFile(filePath);
200 const value = manager.serialize(actual, serializers);
201 const id = snapshotFile.nextId(fullName);
202
203 if (manager.updateSnapshots) {
204 snapshotFile.setSnapshot(id, value);
205 } else {
206 snapshotFile.readFile();
207 strictEqual(value, snapshotFile.getSnapshot(id));
208 }
209 };
210 }
211
212 createFileAssert() {
213 const manager = this;

Callers 2

lazyAssertObjectFunction · 0.80

Calls 7

validateFunctionArrayFunction · 0.85
resolveSnapshotFileMethod · 0.80
nextIdMethod · 0.80
setSnapshotMethod · 0.80
getSnapshotMethod · 0.80
serializeMethod · 0.65
readFileMethod · 0.45

Tested by

no test coverage detected