mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
node:test changes, matching Node 24.22: - t.assert.snapshot(value[, options]) serializes the value with Node's default serializer, JSON.stringify(value, null, 2), or with an options.serializers array literal applied in order, and compares it with assert.strictEqual against the snapshot stored under "<test full name> <n>" in "<entry file>.snapshot". - t.assert.fileSnapshot(value, path[, options]) compares the serialized value with the contents of path. - Snapshot files are read in the form Node writes them, exports[`key`] = `value`; statements, with template escapes and CRLF line endings cooked as in a template literal. - Missing snapshots, unreadable snapshot files and throwing serializers throw Node's ERR_INVALID_STATE errors, with Node's messages. - Running the binary with Node's --test-update-snapshots flag as its first argument records the values and writes the snapshot files after the last test, keys sorted as Node sorts them. The flag is kept out of process.argv and appears in process.execArgv, which is otherwise []. - Snapshot assertions count toward the test's plan. The snapshot fixture compares the reporter output with Node, plain and with SCRIPTC_SAN=1, against a snapshot file Node wrote. The update-mode harness test runs Node and the binary with --test-update-snapshots and compares the files they write. The node:test normalization also drops the "... N lines matching cause stack trace ..." line Node prints for an error cause, with the stack frames it summarizes.
6 lines
986 B
Plaintext
6 lines
986 B
Plaintext
`process.argv[0]` is `"scriptc"`, `process.argv[1]` is the binary's path, and program arguments begin at index 2. In programs that use `node:test`, a leading `--test-update-snapshots` argument is Node's snapshot update flag: it is kept out of `process.argv` and appears in `process.execArgv`, which is otherwise `[]`. `process.version` and `process.versions.node` report the Node.js release the runtime is verified against.
|
|
|
|
Uncaught exceptions print `Uncaught <value>` to stderr instead of Node.js's source excerpt and stack-trace block; thrown strings and numbers print their value. Exit codes and output written before the exception are preserved. Runtime errors expose `message` and Node's `code`, but not `errno`, `syscall`, or `path`.
|
|
|
|
Errors carry no stack frames. `console.log` and `util.inspect` print an Error in Node's stackless form, `[TypeError: message]`, where Node prints `TypeError: message` followed by stack frames; the two agree when `Error.stackTraceLimit` is `0`.
|