Skip to content

Commit 5daa72d

Browse files
committed
adds -t option to test cli
1 parent a127ea3 commit 5daa72d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

packages/polymorphic/src/Polymorphic/Polymorphic.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('packages/polymorphic', () => {
248248

249249
describe('TSDoc output', () => {
250250
describe('Polymorphic', () => {
251-
const docs = parseTSDoc('polymorphic/src');
251+
const docs = parseTSDoc(__dirname);
252252

253253
test('Docs for Polymorphic are generated', () => {
254254
const doc = docs?.find(doc => doc.displayName === 'Polymorph');

tools/cli/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ cli
5151
.command('test')
5252
.description('Tests leafygreen-ui packages with unified config.')
5353
.option('--watch', 'Watch all files you intend to test', false)
54+
.option(
55+
'-t, --testNamePattern <regex>',
56+
'Alias of jest --testNamePattern. Run only tests with a name that matches the regex.',
57+
undefined,
58+
)
5459
.action(test);
5560

5661
/** Lint */

tools/test/src/index.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ const rootDir = process.cwd();
66

77
interface TestCommandOptions {
88
watch: boolean;
9+
testNamePattern?: string;
910
}
1011

1112
export const test = (options: TestCommandOptions) => {
12-
const { watch } = options;
13+
const { watch, testNamePattern } = options;
1314
const configFile = path.resolve(__dirname, '../config/jest.config.js');
1415

1516
spawn(
1617
'jest',
17-
[`--config`, configFile, `--rootDir`, rootDir, watch ? '--watch' : ''],
18+
[
19+
`--config`,
20+
configFile,
21+
`--rootDir`,
22+
rootDir,
23+
watch ? '--watch' : '',
24+
testNamePattern ? `--testNamePattern=${testNamePattern}` : '',
25+
],
1826
{
1927
env: {
2028
...process.env,

0 commit comments

Comments
 (0)