mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
31 lines
569 B
JavaScript
31 lines
569 B
JavaScript
import { setStdout } from '../dist/index.js';
|
|
import stripAnsi from 'strip-ansi';
|
|
|
|
export function setup() {
|
|
const ctx = { messages: [] };
|
|
before(() => {
|
|
setStdout(
|
|
Object.assign({}, process.stdout, {
|
|
write(buf) {
|
|
ctx.messages.push(stripAnsi(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));
|
|
},
|
|
};
|
|
}
|