Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/subcommands/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function bootDevice(this: Simctl): Promise<void> {
args: [this.requireUdid('boot')],
});
} catch (e: any) {
if (e.message?.includes('Unable to boot device in current state: Booted')) {
if (!e.message?.includes('Unable to boot device in current state: Booted')) {
throw e;
}
log.debug(LOG_PREFIX, `Simulator already in 'Booted' state. Continuing`);
Expand Down
32 changes: 32 additions & 0 deletions test/unit/simctl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,38 @@ describe('simctl', function () {
await assert.rejects(() => simctl.setLocation(0, 'Infinity'), TypeError);
});
});

describe('#bootDevice', function () {
let simctl: Simctl;

beforeEach(function () {
simctl = stubSimctl({path: 'xcrun'});
simctl.udid = 'EE76EA77-E975-4198-9859-69DFF74252D2';
});
afterEach(function () {
if (execStub) {
execStub.restore();
}
});

it('should boot the device', async function () {
await simctl.bootDevice();
assert.strictEqual(execStub.getCall(0).args[0], 'boot');
assert.deepStrictEqual(execStub.getCall(0).args[1].args, ['EE76EA77-E975-4198-9859-69DFF74252D2']);
});
it('should not throw if the device is already booted', async function () {
execStub.rejects(new Error('Unable to boot device in current state: Booted'));
await assert.doesNotReject(simctl.bootDevice());
});
it('should rethrow other boot errors', async function () {
execStub.rejects(new Error('Invalid device: EE76EA77-E975-4198-9859-69DFF74252D2'));
await assert.rejects(simctl.bootDevice(), /Invalid device/);
});
it('should throw if udid is not set', async function () {
simctl.udid = null;
await assert.rejects(simctl.bootDevice(), /udid is required/);
});
});
});

function getModuleRootSync(): string {
Expand Down
Loading