npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

typeorm-test-db

v1.0.11

Published

Automated transactional lifecycle helpers for TypeORM tests

Readme

TypeORM Test DB

Visão geral

TypeORM Test DB envolve cada spec do Jest em uma transação de banco de dados isolada. O helper aceita qualquer DataSource inicializado, substitui seu manager durante a spec e restaura o manager original após o rollback. O pacote atende configurações de teste reutilizáveis que mantêm o banco de dados de integração limpo.

Recursos

  • Helper do ciclo de vida do banco de dados de testes para TypeORM com hooks explícitos init e finish.
  • Integração agnóstica de framework ao invocar o ciclo de vida dentro dos hooks do runner de testes.
  • Compatibilidade com MySQL, MariaDB, PostgreSQL, SQLite e Better SQLite 3.
  • Fábricas de dados determinísticas impulsionadas por uma semente de execução reproduzível.
  • Configuração de testes compartilhada que inicializa uma única conexão por worker e executa as specs em paralelo.
  • Relatórios de cobertura gerados por padrão através de pnpm test.
  • Artefatos de build gerados por pnpm build e consumidos pelo Jest para simular uma instalação do pacote.

Instalação

pnpm add -D typeorm-test-db
pnpm add typeorm
npm install -D typeorm-test-db
npm install typeorm
yarn add -D typeorm-test-db
yarn add typeorm

Instale o TypeORM no projeto hospedeiro caso ainda não esteja disponível.

Uso

Crie um arquivo de configuração do Jest que inicialize a conexão e registre o ciclo de vida do banco de dados de testes para TypeORM.

import { afterAll, afterEach, beforeAll, beforeEach } from "@jest/globals";
import { DataSource } from "typeorm";
import { TypeormTestDB } from "typeorm-test-db";

const dataSource = new DataSource({
  type: "mysql",
  host: "127.0.0.1",
  port: 3306,
  username: "root",
  password: "test",
  database: "test",
  synchronize: true,
  entities: [],
});

const lifecycle = TypeormTestDB(dataSource, {
  isolationLevel: "REPEATABLE READ",
});

beforeEach(async () => {
  await lifecycle.init();
});

afterEach(async () => {
  await lifecycle.finish();
});

Importe seus repositórios ou managers dentro das specs. Todas as mutações executadas entre os hooks registrados são revertidas automaticamente.

Execução dos testes

A suíte gera dados reproduzíveis por spec e expõe a variável de ambiente TEST_SEED para controlar a ordem de execução. pnpm test executa o Jest em workers paralelos e força a coleta de cobertura.

Integração contínua

O workflow do GitHub Actions executa o lint e a suíte do Jest contra uma matriz de bancos de dados transacionais. Um job final de agregação falha quando qualquer job da matriz apresenta erro, mantendo o check obrigatório estável mesmo com a adição de novos bancos.

Desenvolvimento

  • pnpm lint verifica a qualidade do código.
  • pnpm build gera o bundle de produção em dist.
  • pnpm test recompila o pacote, executa os testes com dados semente e verifica que o tarball pode ser instalado em um projeto limpo.

Licença

TypeORM Test DB está disponível sob a GNU General Public License v3.0 ou posterior.