diff --git a/apps/ledger-live-desktop/tests/fixtures/common.ts b/apps/ledger-live-desktop/tests/fixtures/common.ts index 46b7b69f1a63..4e20bee6cfce 100644 --- a/apps/ledger-live-desktop/tests/fixtures/common.ts +++ b/apps/ledger-live-desktop/tests/fixtures/common.ts @@ -5,6 +5,7 @@ import * as path from "path"; import { OptionalFeatureMap } from "@ledgerhq/types-live"; import { getEnv, setEnv } from "@ledgerhq/live-env"; import { startSpeculos, stopSpeculos, specs } from "@ledgerhq/live-common/e2e/speculos"; +import invariant from "invariant"; import { Application } from "tests/page"; import { safeAppendFile } from "tests/utils/fileUtils"; @@ -110,7 +111,11 @@ export const test = base.extend({ testInfo.title.replace(/ /g, "_"), specs[speculosApp.name.replace(/ /g, "_")], ); - setEnv("SPECULOS_API_PORT", device?.ports.apiPort?.toString()); + invariant(device, "[E2E Setup] Speculos not started"); + const speculosApiPort = device.ports.apiPort; + invariant(speculosApiPort, "[E2E Setup] speculosApiPort not defined"); + + setEnv("SPECULOS_API_PORT", speculosApiPort.toString()); setEnv("MOCK", ""); if (cliCommands?.length) { diff --git a/libs/ledger-live-common/src/e2e/speculos.ts b/libs/ledger-live-common/src/e2e/speculos.ts index 967631d11206..21d29da34210 100644 --- a/libs/ledger-live-common/src/e2e/speculos.ts +++ b/libs/ledger-live-common/src/e2e/speculos.ts @@ -329,7 +329,6 @@ export async function startSpeculos( try { return await createSpeculosDevice(deviceParams); } catch (e: unknown) { - if (process.env.CI) console.error(e); console.error(e); log("engine", `test ${testName} failed with ${String(e)}`); } diff --git a/libs/speculos-transport/src/index.ts b/libs/speculos-transport/src/index.ts index 35441ba57f34..022ebeafb85c 100644 --- a/libs/speculos-transport/src/index.ts +++ b/libs/speculos-transport/src/index.ts @@ -236,10 +236,10 @@ export async function createSpeculosDevice( let destroyed = false; const destroy = async () => { - if (destroyed) return; + if (destroyed) return Promise.resolve(); destroyed = true; return new Promise((resolve, reject) => { - if (!data[speculosID]) return; + if (!data[speculosID]) return resolve(undefined); delete data[speculosID]; exec(`docker rm -f ${speculosID}`, (error, stdout, stderr) => { if (error) {