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

Function spawnAndAssert

test/common/assertSnapshot.js:192–209  ·  view source on GitHub ↗

* Spawn a process and assert its output against a snapshot. * if you want to automatically update the snapshot, run tests with NODE_REGENERATE_SNAPSHOTS=1 * transform is a function that takes the output and returns a string that will be compared against the snapshot * this is useful for normalizi

(filename, transform = (x) => x, { tty = false, ...options } = {})

Source from the content-addressed store, hash-verified

190 * @returns {Promise<void>}
191 */
192async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...options } = {}) {
193 if (tty && common.isWindows) {
194 test({ skip: 'Skipping pseudo-tty tests, as pseudo terminals are not available on Windows.' });
195 return;
196 }
197 let { flags } = common.parseTestMetadata(filename);
198 if (options.flags) {
199 flags = [...options.flags, ...flags];
200 }
201
202 const executable = tty ? (process.env.PYTHON || 'python3') : process.execPath;
203 const args =
204 tty ?
205 [path.join(__dirname, '../..', 'tools/pseudo-tty.py'), process.execPath, ...flags, filename] :
206 [...flags, filename];
207 const { stdout, stderr } = await common.spawnPromisified(executable, args, options);
208 await assertSnapshot(transform(`${stdout}${stderr}`), filename);
209}
210
211function replaceTestDuration(str) {
212 return str

Calls 4

assertSnapshotFunction · 0.85
transformFunction · 0.70
testFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…