Files
vercel/test/lib/deployment/log.js
Nathan Rajlich fbd9080859 [tests] Add vc build integration test (#7876)
[cli] Add `vc build` integration test

Adds a `vc build` integration test to ensure the ncc'd CLI works as
expected to supplement the unit tests from #7869.

Co-authored-by: Steven <steven@ceriously.com>
2022-05-26 15:05:31 -04:00

34 lines
838 B
JavaScript

const fs = require('fs');
const util = require('util');
const isCi = require('is-ci');
const shouldWriteToFile = isCi || process.env.WRITE_LOGS_TO_FILES;
exports.logWithinTest = logWithinTest;
const dateFormat = new Intl.DateTimeFormat('en-us', {
dateStyle: 'short',
timeStyle: 'medium',
});
function logWithinTest(...inputs) {
const { testPath, currentTestName } =
typeof expect !== 'undefined' ? expect.getState() : {};
const messages = [
dateFormat.format(new Date()),
currentTestName,
...inputs,
].filter(Boolean);
const message = messages
.map(x => (typeof x === 'string' ? x : util.inspect(x)))
.join('\t');
if (shouldWriteToFile && testPath) {
const filePath = `${testPath}.artifact.log`;
fs.appendFileSync(filePath, `${message.trim()}\n`);
}
console.log(message.trim());
}