registerSession(connection, { role, sessionId }) {
    let session;

    if (this._assertConnectionIsNotInSession(connection)) {
      session = this._sessionsById.get(sessionId);
    } else {
      session = this._sessionsByConnection.get(connection);
    }

    if (!session) {
      session = new DetoxSession(sessionId);
      this._sessionsById.set(sessionId, session);
    }

    this._sessionsByConnection.set(connection, session);
    session[role] = connection;
    return session;
  }
@param {DetoxConnection} connection
@param {'tester' | 'app'} role
@param {string} sessionId
@returns {DetoxSession}