Repository: sequelize/sequelize
File: packages/core/test/support.ts (TypeScript)

Code before:
}

export function createSequelizeInstance(options: Options<AbstractDialect> = {}): Sequelize {
  const dialect = getTestDialect();

  const config = Config[dialect];

  const sequelizeOptions = defaults(options, {
    database: config.database,
    username: config.username,
    password: config.password,
    host: options.host || config.host,
    logging: process.env.SEQ_LOG ? console.debug : false,
    port: options.port || process.env.SEQ_PORT || config.port,
    pool: config.pool,
    dialectOptions: options.dialectOptions || config.dialectOptions || {},
    minifyAliases: options.minifyAliases || config.minifyAliases,
    // the test suite was written before CLS was turned on by default.
    disableClsTransactions: true,
  } as const);

  if (config.storage || config.storage === '') {
    sequelizeOptions.storage = config.storage;
  }

  if (dialect === 'db2') {
    const sequelizeDb2Options: Options<Db2Dialect> = {
      ...sequelizeOptions,
      dialect: Db2Dialect,
    };

    return getSequelizeInstance(sequelizeDb2Options);
  }

  if (dialect === 'postgres') {
    const sequelizePostgresOptions: Options<PostgresDialect> = {
      ...sequelizeOptions,
      dialect: PostgresDialect,
      native: process.env.DIALECT === 'postgres-native',
    };

    return getSequelizeInstance(sequelizePostgresOptions);
  }

  return getSequelizeInstance(sequelizeOptions);
}

export function getConnectionOptionsWithoutPool() {
  // Do not break existing config object - shallow clone before `delete config.pool`
  const config = { ...Config[getTestDialect()] };
  delete config.pool;

Review comment (suggestion):
is that intended?
If yes, I'll just re-approve

This will eventually be re-added as we'll require specifying the class instead of the name at some point

Code after:

export function createSequelizeInstance(options: Options<AbstractDialect> = {}): Sequelize {
  const dialect = getTestDialect();

  const config = Config[dialect];

  const sequelizeOptions = defaults(options, {
    database: config.database,
    username: config.username,
    password: config.password,
    host: options.host || config.host,
    logging: process.env.SEQ_LOG ? console.debug : false,
    port: options.port || process.env.SEQ_PORT || config.port,
    pool: config.pool,
    dialectOptions: options.dialectOptions || config.dialectOptions || {},
    minifyAliases: options.minifyAliases || config.minifyAliases,
    // the test suite was written before CLS was turned on by default.
    disableClsTransactions: true,
  } as const);

  if (config.storage || config.storage === '') {
    sequelizeOptions.storage = config.storage;
  }

  if (dialect === 'postgres') {
    const sequelizePostgresOptions: Options<PostgresDialect> = {
      ...sequelizeOptions,
      dialect: PostgresDialect,
      native: process.env.DIALECT === 'postgres-native',
    };

    return getSequelizeInstance(sequelizePostgresOptions);
  }

  return getSequelizeInstance(sequelizeOptions);
}

export function getConnectionOptionsWithoutPool() {
  // Do not break existing config object - shallow clone before `delete config.pool`
  const config = { ...Config[getTestDialect()] };
  delete config.pool;

  return config;
}

export function getSequelizeInstance(options?: Options<AbstractDialect>): Sequelize {
  options ??= {};
  options.dialect ||= getTestDialect();

  return new Sequelize(options);
}