本文整理匯總了TypeScript中intercept-stdout類的典型用法代碼示例。如果您正苦於以下問題:TypeScript intercept-stdout類的具體用法?TypeScript intercept-stdout怎麽用?TypeScript intercept-stdout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了intercept-stdout類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("can write json to stdout", async () => {
const input = `
[B]: test
<A>: test
- [B]
+ <C>: test
`;
const request: IArgdownRequest = {
input,
process: ["parse-input", "build-model", "export-json", "stdout-json"],
logLevel: "error"
};
let capturedText = "";
var unhook_intercept = intercept(function(text: string) {
capturedText += text;
return "";
});
await argdown.runAsync(request);
unhook_intercept();
expect(capturedText).to.not.equal("");
expect(capturedText.startsWith(`{`)).to.be.true;
expect(capturedText.endsWith(`}`)).to.be.true;
});
示例2: stdout
it('Compare output', () => {
let actual = '';
let message = 'test';
let intercept = stdout(output => actual += output);
Log.info(message);
intercept();
assert.equal(actual, `${colors.green('>>')} ${message}\n`);
});