0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
astro/packages/upgrade/test/utils.js
Cristopher f47b347da8
chore(deps): replace strip-ansi with native module (#12118)
* chore(deps): replace strip-ansi with native module

* chore: changeset

---------

Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com>
2024-10-04 11:21:03 +02:00

32 lines
651 B
JavaScript

import { before, beforeEach } from 'node:test';
import { stripVTControlCharacters } from 'node:util';
import { setStdout } from '../dist/index.js';
export function setup() {
const ctx = { messages: [] };
before(() => {
setStdout(
Object.assign({}, process.stdout, {
write(buf) {
ctx.messages.push(stripVTControlCharacters(String(buf)).trim());
return true;
},
}),
);
});
beforeEach(() => {
ctx.messages = [];
});
return {
messages() {
return ctx.messages;
},
length() {
return ctx.messages.length;
},
hasMessage(content) {
return !!ctx.messages.find((msg) => msg.includes(content));
},
};
}