Skip to content

Commit

Permalink
feature: @supertape/formatter-progress-bar: add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jun 4, 2024
1 parent 095ca2e commit 188ab81
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/formatter-progress-bar/lib/progress-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export function createFormatter(bar) {
out,
store,
}),
comment: comment({
out,
}),
end: end({
barStore,
out,
Expand Down Expand Up @@ -110,6 +113,10 @@ export const fail = ({out, store}) => ({at, count, message, operator, result, ex
out('');
};

export const comment = ({out}) => ({message}) => {
out(`# ${message}`);
};

export const end = ({barStore, out}) => ({count, passed, failed, skiped}) => {
barStore().stop();

Expand Down
55 changes: 55 additions & 0 deletions packages/formatter-progress-bar/lib/progress-bar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,61 @@ test('supertape: format: progress bar', async (t) => {
t.end();
});

test('supertape: format: progress bar: comment', async (t) => {
const successFn = (t) => {
t.ok(true);
t.end();
};

const successMessage = 'progress bar: success';

const failFn = (t) => {
t.comment('second');
t.ok(false);
t.end();
};

const failMessage = 'progress bar: fail';
const {CI} = env;

env.CI = 1;

const {
run,
test,
stream,
} = await createTest({
formatter: progressBar,
});

test(successMessage, successFn);
test(failMessage, failFn);

const [result] = await Promise.all([
pull(stream, 11),
run(),
]);

env.CI = CI;

const expected = montag`
TAP version 13
# second
# progress bar: fail
❌ not ok 2 should be truthy
---
operator: ok
expected: |-
true
result: |-
false
`;

t.equal(result, expected);
t.end();
});

test('supertape: format: progress bar: diff', async (t) => {
const fn = (t) => {
t.equal(1, 2);
Expand Down

0 comments on commit 188ab81

Please sign in to comment.