-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re: #921
- Loading branch information
Showing
10 changed files
with
268 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Box, Text } from 'ink' | ||
import React, { FC, useLayoutEffect, useState } from 'react' | ||
import { TestBase } from '@tapjs/core' | ||
import { Result } from 'tap-parser' | ||
import { Reporter } from './index.js' | ||
import { listenCleanup } from './listen-cleanup.js' | ||
import { ResultDetailList } from './result-detail-list.js' | ||
|
||
type Color = 'red' | 'green' | 'cyan' | 'magenta' | ||
const getColor = (r: Result) => | ||
r.skip ? 'cyan' : r.todo ? 'magenta' : !r.ok ? 'red' : 'green' | ||
const DOTS: Color[] = [] | ||
const Dots: FC<{ test: TestBase }> = ({ test }) => { | ||
const [dots, updateDots] = useState<Color[]>([]) | ||
useLayoutEffect( | ||
() => | ||
listenCleanup(test, 'assert', r => { | ||
DOTS.push(getColor(r)) | ||
updateDots([...DOTS]) | ||
}), | ||
[dots] | ||
) | ||
const width = Math.max(15, columns) | ||
return ( | ||
<Box width={width} flexWrap="wrap"> | ||
{dots.map((c, i) => ( | ||
<Text key={i} color={c}> | ||
. | ||
</Text> | ||
))} | ||
</Box> | ||
) | ||
} | ||
|
||
const { columns = 70 } = process.stdout | ||
|
||
export const Dot: Reporter = ({ test }) => ( | ||
<Box flexDirection="column"> | ||
<Dots test={test} /> | ||
<ResultDetailList | ||
test={test} | ||
filter={({ parser, counts }) => | ||
!parser.ok || !!counts.todo || !!counts.fail | ||
} | ||
/> | ||
</Box> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Box } from 'ink' | ||
import React from 'react' | ||
import { Reporter } from './index.js' | ||
import { ResultDetailList } from './result-detail-list.js' | ||
|
||
export const Min: Reporter = ({ test }) => ( | ||
<Box flexDirection="column"> | ||
<ResultDetailList | ||
test={test} | ||
filter={({ parser, counts }) => | ||
!parser.ok || !!counts.todo || !!counts.fail | ||
} | ||
/> | ||
</Box> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/dot.tsx > TAP > no comments or passes > must match snapshot 1`] = ` | ||
[32m.[31m.[36m.[32m.[35m.[32m.[36m.[35m.[32m..[39m | ||
[1m[41m[38;2;255;255;255m FAIL [39m[49m[22m one [31m1 failed[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[31m✖[39m[22m nope | ||
[48;5;234m[2mtest/fixtures/get-test.ts [22m[49m | ||
[48;5;234m[38;2;143;165;209m14 [38;5;252m [38;2;121;192;255mawait[38;5;252m sleep[38;2;147;205;255m([38;5;113m64[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m15 [38;5;252m [38;2;215;95;255m[3m// children end out of order[23m[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m16 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: zro [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'zro'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m()[38;5;252m => [38;2;147;205;255m{})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m17 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: one [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'one'[38;2;147;205;255m,[38;5;252m t => t[38;2;147;205;255m.[38;5;252mfail[38;2;147;205;255m([38;5;113m'nope'[38;2;147;205;255m))[39m[49m | ||
[48;5;234m[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[1m┛[22m [39m[49m | ||
[48;5;234m[38;2;143;165;209m18 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: two [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'two'[38;2;147;205;255m,[38;5;252m t => [38;2;147;205;255m{[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m19 [38;5;252m t[38;2;147;205;255m.[38;5;252mpass[38;2;147;205;255m([38;5;113m'skip'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m{[38;5;252m skip: [38;5;113mtrue[38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m20 [38;5;252m t[38;2;147;205;255m.[38;5;252mcomment[38;2;147;205;255m([38;5;113m'comment in two'[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m21 [38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
XXX mock stack XXX | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m fur [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m svn [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo [35mmessage[39m | ||
` | ||
|
||
exports[`test/dot.tsx > TAP > yes comments and passes > must match snapshot 1`] = ` | ||
[32m.[31m.[36m.[32m.[35m.[32m.[36m.[35m.[32m...[31m.[36m.[32m.[35m.[32m.[36m.[35m.[32m..[39m | ||
[1m[41m[38;2;255;255;255m FAIL [39m[49m[22m one [31m1 failed[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[31m✖[39m[22m nope | ||
[48;5;234m[2mtest/fixtures/get-test.ts [22m[49m | ||
[48;5;234m[38;2;143;165;209m14 [38;5;252m [38;2;121;192;255mawait[38;5;252m sleep[38;2;147;205;255m([38;5;113m64[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m15 [38;5;252m [38;2;215;95;255m[3m// children end out of order[23m[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m16 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: zro [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'zro'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m()[38;5;252m => [38;2;147;205;255m{})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m17 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: one [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'one'[38;2;147;205;255m,[38;5;252m t => t[38;2;147;205;255m.[38;5;252mfail[38;2;147;205;255m([38;5;113m'nope'[38;2;147;205;255m))[39m[49m | ||
[48;5;234m[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[1m┛[22m [39m[49m | ||
[48;5;234m[38;2;143;165;209m18 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: two [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'two'[38;2;147;205;255m,[38;5;252m t => [38;2;147;205;255m{[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m19 [38;5;252m t[38;2;147;205;255m.[38;5;252mpass[38;2;147;205;255m([38;5;113m'skip'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m{[38;5;252m skip: [38;5;113mtrue[38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m20 [38;5;252m t[38;2;147;205;255m.[38;5;252mcomment[38;2;147;205;255m([38;5;113m'comment in two'[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m21 [38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
XXX mock stack XXX | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m fur [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m svn [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo [35mmessage[39m | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/min.tsx > TAP > no comments or passes > must match snapshot 1`] = ` | ||
[1m[41m[38;2;255;255;255m FAIL [39m[49m[22m one [31m1 failed[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[31m✖[39m[22m nope | ||
[48;5;234m[2mtest/fixtures/get-test.ts [22m[49m | ||
[48;5;234m[38;2;143;165;209m14 [38;5;252m [38;2;121;192;255mawait[38;5;252m sleep[38;2;147;205;255m([38;5;113m64[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m15 [38;5;252m [38;2;215;95;255m[3m// children end out of order[23m[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m16 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: zro [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'zro'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m()[38;5;252m => [38;2;147;205;255m{})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m17 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: one [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'one'[38;2;147;205;255m,[38;5;252m t => t[38;2;147;205;255m.[38;5;252mfail[38;2;147;205;255m([38;5;113m'nope'[38;2;147;205;255m))[39m[49m | ||
[48;5;234m[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[1m┛[22m [39m[49m | ||
[48;5;234m[38;2;143;165;209m18 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: two [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'two'[38;2;147;205;255m,[38;5;252m t => [38;2;147;205;255m{[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m19 [38;5;252m t[38;2;147;205;255m.[38;5;252mpass[38;2;147;205;255m([38;5;113m'skip'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m{[38;5;252m skip: [38;5;113mtrue[38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m20 [38;5;252m t[38;2;147;205;255m.[38;5;252mcomment[38;2;147;205;255m([38;5;113m'comment in two'[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m21 [38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
XXX mock stack XXX | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m fur [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m svn [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo [35mmessage[39m | ||
` | ||
|
||
exports[`test/min.tsx > TAP > yes comments and passes > must match snapshot 1`] = ` | ||
[1m[41m[38;2;255;255;255m FAIL [39m[49m[22m one [31m1 failed[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[31m✖[39m[22m nope | ||
[48;5;234m[2mtest/fixtures/get-test.ts [22m[49m | ||
[48;5;234m[38;2;143;165;209m14 [38;5;252m [38;2;121;192;255mawait[38;5;252m sleep[38;2;147;205;255m([38;5;113m64[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m15 [38;5;252m [38;2;215;95;255m[3m// children end out of order[23m[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m16 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: zro [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'zro'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m()[38;5;252m => [38;2;147;205;255m{})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m17 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: one [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'one'[38;2;147;205;255m,[38;5;252m t => t[38;2;147;205;255m.[38;5;252mfail[38;2;147;205;255m([38;5;113m'nope'[38;2;147;205;255m))[39m[49m | ||
[48;5;234m[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[1m┛[22m [39m[49m | ||
[48;5;234m[38;2;143;165;209m18 [38;5;252m [38;2;121;192;255mconst[38;5;252m [38;2;147;205;255m{[38;5;252m subtest: two [38;2;147;205;255m}[38;5;252m = tb[38;2;147;205;255m.[38;5;252mtest[38;2;147;205;255m([38;5;113m'two'[38;2;147;205;255m,[38;5;252m t => [38;2;147;205;255m{[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m19 [38;5;252m t[38;2;147;205;255m.[38;5;252mpass[38;2;147;205;255m([38;5;113m'skip'[38;2;147;205;255m,[38;5;252m [38;2;147;205;255m{[38;5;252m skip: [38;5;113mtrue[38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m20 [38;5;252m t[38;2;147;205;255m.[38;5;252mcomment[38;2;147;205;255m([38;5;113m'comment in two'[38;2;147;205;255m)[38;5;252m [39m[49m | ||
[48;5;234m[38;2;143;165;209m21 [38;5;252m [38;2;147;205;255m})[38;5;252m [39m[49m | ||
XXX mock stack XXX | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m fur [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo | ||
[1m[48;2;136;0;136m[38;2;255;255;255m TODO [39m[49m[22m svn [35m1 todo[39m of [1m1[22m [2m{TIME}[22m | ||
[1m[35m☐[39m[22m todo [35mmessage[39m | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import chalk from './fixtures/chalk.js' | ||
|
||
import { LoadedConfig } from '@tapjs/config' | ||
import { Box, Text } from 'ink' | ||
import { render } from 'ink-testing-library' | ||
import React from 'react' | ||
import t from 'tap' | ||
import { getTest } from './fixtures/get-test.js' | ||
|
||
const config = {} as unknown as LoadedConfig | ||
|
||
const { Dot } = (await t.mockImport('../dist/esm/dot.js', { | ||
chalk, | ||
'../dist/esm/ms.js': { | ||
ms: () => '{TIME}', | ||
}, | ||
'../dist/esm/hooks/use-test-time.js': { | ||
useTestTime: () => 123, | ||
}, | ||
'../dist/esm/stack.js': { | ||
Stack: () => ( | ||
<Box> | ||
<Text>{'XXX mock stack XXX'}</Text> | ||
</Box> | ||
), | ||
}, | ||
})) as typeof import('../dist/esm/dot.js') | ||
|
||
t.test('no comments or passes', async t => { | ||
const tb = getTest() | ||
const app = render(<Dot config={config} test={tb} />) | ||
tb.go() | ||
await tb.concat() | ||
t.matchSnapshot(app.lastFrame()) | ||
}) | ||
|
||
t.test('yes comments and passes', async t => { | ||
const tb = getTest() | ||
const app = render(<Dot config={config} test={tb} />) | ||
tb.go() | ||
await tb.concat() | ||
t.matchSnapshot(app.lastFrame()) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import chalk from './fixtures/chalk.js' | ||
|
||
import { LoadedConfig } from '@tapjs/config' | ||
import { Box, Text } from 'ink' | ||
import { render } from 'ink-testing-library' | ||
import React from 'react' | ||
import t from 'tap' | ||
import { getTest } from './fixtures/get-test.js' | ||
|
||
const config = {} as unknown as LoadedConfig | ||
|
||
const { Min } = (await t.mockImport('../dist/esm/min.js', { | ||
chalk, | ||
'../dist/esm/ms.js': { | ||
ms: () => '{TIME}', | ||
}, | ||
'../dist/esm/hooks/use-test-time.js': { | ||
useTestTime: () => 123, | ||
}, | ||
'../dist/esm/stack.js': { | ||
Stack: () => ( | ||
<Box> | ||
<Text>{'XXX mock stack XXX'}</Text> | ||
</Box> | ||
), | ||
}, | ||
})) as typeof import('../dist/esm/min.js') | ||
|
||
t.test('no comments or passes', async t => { | ||
const tb = getTest() | ||
const app = render(<Min config={config} test={tb} />) | ||
tb.go() | ||
await tb.concat() | ||
t.matchSnapshot(app.lastFrame()) | ||
}) | ||
|
||
t.test('yes comments and passes', async t => { | ||
const tb = getTest() | ||
const app = render(<Min config={config} test={tb} />) | ||
tb.go() | ||
await tb.concat() | ||
t.matchSnapshot(app.lastFrame()) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters