Skip to content

Commit d9ef2b2

Browse files
Merge pull request #55 from testingbot/feat/TB-378-disable-animations
feat(maestro): --disable-animations / --no-disable-animations (TB-378)
2 parents 46f3914 + 2d3edf0 commit d9ef2b2

5 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ testingbot maestro <app> <flows...> [options]
112112
| `--real-device` | Use a real device instead of emulator/simulator |
113113
| `--device-matrix <cells>` | Run every flow on each listed device in one go. Cells are `<device>[:<version>][:real]`, comma-separated or repeatable. Cannot be combined with `--device` or `--deviceVersion`; `--real-device` (or an `.ipa` app) applies to every cell |
114114
| `--orientation <orientation>` | Screen orientation: PORTRAIT or LANDSCAPE |
115+
| `--disable-animations` | Turn off device animations (Android animation scales, iOS Reduce Motion). `--no-disable-animations` keeps them on. Overrides `platform.*.disableAnimations` in config.yaml |
115116
| `--device-locale <locale>` | Device locale (e.g., "en_US", "de_DE") |
116117
| `--timezone <timezone>` | Timezone (e.g., "America/New_York", "Europe/London") |
117118

‎src/cli.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,14 @@ program
629629
'--google-play',
630630
'Use the Google Play Store-enabled version (Android emulator only).',
631631
)
632+
.option(
633+
'--disable-animations',
634+
'Turn off device animations (Android animation scales, iOS Reduce Motion). Overrides platform.*.disableAnimations in config.yaml.',
635+
)
636+
.option(
637+
'--no-disable-animations',
638+
'Keep device animations on, even where config.yaml sets platform.*.disableAnimations.',
639+
)
632640
.option(
633641
'--orientation <orientation>',
634642
'Screen orientation: PORTRAIT or LANDSCAPE.',
@@ -963,6 +971,7 @@ program
963971
retry: args.retry,
964972
debug: args.debug,
965973
googlePlayStore: args.googlePlay,
974+
disableAnimations: args.disableAnimations,
966975
configFile: args.config,
967976
groups: args.groups,
968977
metadata,

‎src/models/maestro_options.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ export interface MaestroRunOptions {
5151
*/
5252
secretEnv?: Record<string, string>;
5353
version?: string;
54+
/**
55+
* Turns device animations off (true) or keeps them on (false), overriding
56+
* `platform.ios/android.disableAnimations` in config.yaml. Left out when
57+
* neither --disable-animations nor --no-disable-animations is given, so
58+
* the config file (or the device default) applies.
59+
*/
60+
disableAnimations?: boolean;
5461
}
5562

5663
/** One device of a --device-matrix run. */
@@ -125,6 +132,7 @@ export default class MaestroOptions {
125132
private _configFile?: string;
126133
private _groups?: string[];
127134
private _googlePlayStore: boolean;
135+
private _disableAnimations?: boolean;
128136
// Metadata
129137
private _metadata?: RunMetadata;
130138

@@ -165,6 +173,7 @@ export default class MaestroOptions {
165173
configFile?: string;
166174
groups?: string[];
167175
googlePlayStore?: boolean;
176+
disableAnimations?: boolean;
168177
metadata?: RunMetadata;
169178
otherApps?: string[];
170179
appBinaryId?: number;
@@ -241,6 +250,7 @@ export default class MaestroOptions {
241250
this._configFile = options?.configFile;
242251
this._groups = options?.groups;
243252
this._googlePlayStore = options?.googlePlayStore ?? false;
253+
this._disableAnimations = options?.disableAnimations;
244254
this._metadata = options?.metadata;
245255
}
246256

@@ -412,6 +422,10 @@ export default class MaestroOptions {
412422
return this._googlePlayStore;
413423
}
414424

425+
public get disableAnimations(): boolean | undefined {
426+
return this._disableAnimations;
427+
}
428+
415429
public getMaestroOptions(): MaestroRunOptions | undefined {
416430
const opts: MaestroRunOptions = {};
417431

@@ -430,6 +444,9 @@ export default class MaestroOptions {
430444
if (this._maestroVersion) {
431445
opts.version = this._maestroVersion;
432446
}
447+
if (this._disableAnimations !== undefined) {
448+
opts.disableAnimations = this._disableAnimations;
449+
}
433450

434451
return Object.keys(opts).length > 0 ? opts : undefined;
435452
}

‎tests/cli.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,24 @@ describe('TestingBotCTL CLI', () => {
15451545
});
15461546
});
15471547

1548+
test.each([
1549+
[[], undefined],
1550+
[['--disable-animations'], true],
1551+
[['--no-disable-animations'], false],
1552+
])('%j sets disableAnimations to %s', async (flags, expected) => {
1553+
await program.parseAsync([
1554+
'node',
1555+
'cli',
1556+
'maestro',
1557+
'app.apk',
1558+
'./flows',
1559+
...(flags as string[]),
1560+
]);
1561+
expect(lastConstructorOptions<Opts>(Maestro).disableAnimations).toBe(
1562+
expected,
1563+
);
1564+
});
1565+
15481566
test('-e lands in env and --secret-env in secretEnv', async () => {
15491567
await program.parseAsync([
15501568
'node',

‎tests/models/maestro_options.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,21 @@ describe('MaestroOptions', () => {
503503
});
504504
});
505505

506+
describe('disableAnimations', () => {
507+
it('is omitted from getMaestroOptions when not given', () => {
508+
const options = new MaestroOptions('app.apk', './flows', 'Pixel 8');
509+
expect(options.disableAnimations).toBeUndefined();
510+
expect(options.getMaestroOptions()).toBeUndefined();
511+
});
512+
513+
it.each([true, false])('is emitted as disableAnimations: %s', (value) => {
514+
const options = new MaestroOptions('app.apk', './flows', 'Pixel 8', {
515+
disableAnimations: value,
516+
});
517+
expect(options.getMaestroOptions()).toEqual({ disableAnimations: value });
518+
});
519+
});
520+
506521
describe('secretEnv', () => {
507522
it('is undefined by default and omitted from getMaestroOptions', () => {
508523
const options = new MaestroOptions('app.apk', './flows', 'Pixel 8');

0 commit comments

Comments
 (0)