Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function buildArgs(overrides: Record<string, unknown> = {}) {
} as any;
}

describe('createRun no-flag default targeting (issue #2765)', () => {
describe('createRun device targeting', () => {
let chdirSpy: jest.SpyInstance;

beforeEach(() => {
Expand Down Expand Up @@ -153,6 +153,31 @@ describe('createRun no-flag default targeting (issue #2765)', () => {
expect(runOnSimulator).not.toHaveBeenCalled();
});

test('connected iPhone + --udid -> does not resolve a fallback simulator', async () => {
(listDevices as jest.Mock).mockResolvedValue([physicalDevice]);
(getFallbackSimulator as jest.Mock).mockImplementation(() => {
throw new Error('No simulator available');
});

await createRun({platformName: 'ios'})(
[],
buildCtx(),
buildArgs({udid: physicalDevice.udid}),
);

expect(getFallbackSimulator).not.toHaveBeenCalled();
expect(runOnDevice).toHaveBeenCalledTimes(1);
expect(runOnDevice).toHaveBeenCalledWith(
physicalDevice,
'ios',
'Debug',
'Demo',
expect.anything(),
expect.anything(),
);
expect(runOnSimulator).not.toHaveBeenCalled();
});

test('no devices, no flags -> launches fallback simulator', async () => {
(listDevices as jest.Mock).mockResolvedValue([fallbackSimulator]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const createRun =
}
}

const fallbackSimulator =
const getFallbackDevice = () =>
platformName === 'ios' || platformName === 'tvos'
? getFallbackSimulator(args)
: devices[0];
Expand Down Expand Up @@ -268,7 +268,7 @@ const createRun =
);
const connectedDevices = devices.filter(({type}) => type === 'device');

const targetSimulator = bootedSimulators[0] ?? fallbackSimulator;
const targetSimulator = bootedSimulators[0] ?? getFallbackDevice();

if (bootedSimulators.length === 0) {
logger.info(
Expand Down Expand Up @@ -414,7 +414,7 @@ const createRun =
mode,
scheme,
args,
matchedSimulator ?? fallbackSimulator,
matchedSimulator ?? getFallbackDevice(),
);
} else {
runOnSimulator(
Expand All @@ -423,7 +423,7 @@ const createRun =
mode,
scheme,
args,
fallbackSimulator,
getFallbackDevice(),
);
}
};
Expand Down
Loading