Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function createPercyServer(percy, port) {
if (cmd === 'reset') {
// the reset command will reset testing mode and clear any logs
percy.testing = {};
logger.instance.messages.clear();
logger.instance.reset();
} else if (cmd === 'version') {
// the version command will update the api version header for testing
percy.testing.version = body;
Expand Down Expand Up @@ -262,7 +262,7 @@ export function createPercyServer(percy, port) {
}))
// returns an array of raw logs from the logger
.route('get', '/test/logs', (req, res) => res.json(200, {
logs: Array.from(logger.instance.messages)
logs: logger.instance.query(() => true)
}))
// serves a very basic html page for testing snapshots
.route('get', '/test/snapshot', (req, res) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ function processSnapshotResources({ domSnapshot, resources, ...snapshot }) {
resources = resources.flat();

// include associated snapshot logs matched by meta information
resources.push(createLogResource(logger.query(log => (
log.meta.snapshot?.testCase === snapshot.meta.snapshot.testCase && log.meta.snapshot?.name === snapshot.meta.snapshot.name
))));
resources.push(createLogResource(logger.snapshotLogs(snapshot.meta.snapshot)));
logger.evictSnapshot(snapshot.meta.snapshot);

if (process.env.PERCY_GZIP) {
for (let index = 0; index < resources.length; index++) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ describe('API Server', () => {
beforeEach(async () => {
process.env.PERCY_TOKEN = 'TEST_TOKEN';
percy = await Percy.start({ testing: true });
logger.instance.messages.clear();
logger.instance.reset();
});

afterEach(() => {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export async function setupTest({
loggerTTY,
apiDelay
} = {}) {
// Why: downstream packages (cli-exec, cli-snapshot, percy core, etc.) use
// mockfs as their default fs sandbox, and the disk-backed logger flakes
// ENOENT against mockfs's volume mid-flush — which leaks the fallback
// warning into another test's captured stderr. Keep these tests in
// unbounded in-memory mode (master parity) — the disk path has its own
// dedicated coverage in logger.test.js.
process.env.PERCY_LOGS_IN_MEMORY = '1';
await api.mock({ delay: apiDelay });
await logger.mock({ isTTY: loggerTTY });
await resetPercyConfig(resetConfig);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ describe('Percy', () => {
percy.log.info('cli_test');
percy.log.info('ci_test', {}, true);
const logsObject = {
clilogs: Array.from(logger.instance.messages)
clilogs: logger.instance.query(() => true)
};

const content = base64encode(Pako.gzip(JSON.stringify(logsObject)));
Expand Down
3 changes: 3 additions & 0 deletions packages/logger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Object.defineProperties(logger, {
constructor: { get: () => Logger },
instance: { get: () => new Logger() },
query: { value: (...args) => logger.instance.query(...args) },
snapshotLogs: { value: (...args) => logger.instance.snapshotLogs(...args) },
evictSnapshot: { value: (...args) => logger.instance.evictSnapshot(...args) },
reset: { value: (...args) => logger.instance.reset(...args) },
format: { value: (...args) => logger.instance.format(...args) },
loglevel: { value: (...args) => logger.instance.loglevel(...args) },
timeit: { get: () => new TimeIt(logger.instance.group('timer')) },
Expand Down
Loading
Loading