Skip to content

Commit 15f3de0

Browse files
authored
Feat: pass along Jest testNamePattern argument if provided (#182)
1 parent 374043e commit 15f3de0

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

.changeset/great-mayflies-explain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-owl': minor
3+
---
4+
5+
Ability to pass along Jest testNamePattern when the argument is provided

docs/cli/testing-the-app.mdx

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ Use the `test` command to run the app on the simulator, either comparing screens
1111

1212
#### Options
1313

14-
| Name | Required | Default | Options/Types | Description |
15-
| ------------------ | -------- | ----------------- | --------------- | ----------------------------------------------- |
16-
| `--config`, `-c` | false | ./owl.config.json | String | Path to the configuration file |
17-
| `--platform`, `-p` | true | - | `ios`,`android` | The platform the app should be built on |
18-
| `--update`, `-u` | true | false | Boolean | A flag about rewriting existing baseline images |
14+
| Name | Required | Default | Options/Types | Description |
15+
| ------------------------- | -------- | ----------------- | --------------- | ------------------------------------------------- |
16+
| `--config`, `-c` | false | ./owl.config.json | String | Path to the configuration file |
17+
| `--platform`, `-p` | true | - | `ios`,`android` | The platform the app should be built on |
18+
| `--update`, `-u` | true | false | Boolean | A flag about rewriting existing baseline images |
19+
| `--testNamePattern`, `-t` | false | false | String | Run only tests with a name that matches the regex |
20+
| `--testPathPattern`, `-p` | false | false | String | A regexp string matched against all tests path |
1921

2022
When comparing images, any difference in the current vs baseline will fail the test.
2123

lib/cli/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ const updateOption: Options = {
2828
default: false,
2929
};
3030

31-
const testPathPatternOption: Options = {
31+
const testNamePattern: Options = {
3232
alias: 't',
33+
describe: 'Run only tests with a name that matches the regex',
34+
type: 'string',
35+
};
36+
37+
const testPathPatternOption: Options = {
38+
alias: 'p',
3339
describe: 'Run Test for a matching path pattern',
3440
type: 'string',
3541
default: '',
@@ -44,6 +50,7 @@ const builderOptionsTest = {
4450
config: configOption,
4551
platform: plaformOption,
4652
update: updateOption,
53+
testNamePattern: testNamePattern,
4754
testPathPattern: testPathPatternOption,
4855
};
4956

lib/cli/run.ts

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ export const runHandler = async (args: CliRunOptions) => {
136136
jestCommandArgs.push(`--json --outputFile=${outputFile}`);
137137
}
138138

139+
if (args.testNamePattern) {
140+
jestCommandArgs.push(`-t`, `${args.testNamePattern}`);
141+
}
142+
139143
const jestCommand = jestCommandArgs.join(' ');
140144

141145
logger.print(

lib/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface CliRunOptions extends Arguments {
1111
platform: Platform;
1212
config: string;
1313
update: boolean;
14+
testNamePattern: string;
1415
testPathPattern: string;
1516
}
1617

0 commit comments

Comments
 (0)