Dev Toolsv0.1.11
@tekir/testing
HTTP test client, fluent assertions, and model factories.
Installation
$
bun add -d @tekir/testingFeatures
- createTestApp() boots app on random port for testing
- client() with get/post/put/delete methods
- Fluent assertions: assertOk, assertJson, assertStatus
- defineFactory() for model test data generation
- fakeTime(), assertThrows() test helpers
- setupTestDb() for database test isolation
Quick Example
TypeScript
import { createTestApp } from '@tekir/testing'
const { request } = await createTestApp()
const res = await request.get('/users')
res.assertOk()
res.assertJsonContains({ length: 3 })Changelog
v0.1.11LatestSeptember 16, 2026
- Published output now uses the shared Node-targeted ESM bundle pipeline with external dependencies and generated TypeScript declarations, while Bun consumers keep the native source export.
v0.1.10July 23, 2026
- Package metadata now follows the shared compatible
0.1.xdependency range used by this coordinated Tekir release.
v0.1.9July 16, 2026
- Test applications await startup and shut down after migration failures, explicit migrations require
@tekir/db, setup errors are surfaced, and authenticated clients retain thehead()method.
v0.1.8June 13, 2026
- Table names in test database helpers are now validated and any embedded quote is escaped, so a quoted table name cannot break the query.
FakeDatenow forwards its constructor arguments unchanged, sonew Date(timestampNumber)parses correctly instead of producing an Invalid Date.- The in-memory database override now uses a shallow structural clone (only swapping the sqlite path to
:memory:) instead of a JSON round-trip, so function/Date/undefinedfields in the config survive. - JSON assertions (
assertJson/assertJsonContains/assertJsonPath/assertError) now compare structurally and are independent of key order. - Found and fixed with Fable.
v0.1.7May 8, 2026
defineFactory(defaults, model)now accepts a model that implements onlycreateor onlycreateMany. Both methods are optional on theFactoryModel<T>interface; callingfactory.create()against a model withoutcreate(orfactory.createMany()withoutcreateMany) throws a clear runtime error pointing at the missing method. Lets you back a factory with a thin wrapper around either an ORM's bulk insert or a single-row insert without faking the other.
v0.1.6May 3, 2026
- Adapts to
@tekir/core0.1.8's explicit autoload paths.createTestApp()now auto-detectsenv.ts,config/, andstart/under the app root and forwards them totekir(), so existing test suites continue to work with no changes. PassenvFile: false,configDir: false, orstartDir: falseto opt out of any of them, or pass a custom path string to override.
v0.1.5May 3, 2026
- Tests now run on Node as well as Bun. The package detects the runtime at load time and re-exports
bun:teston Bun (built-in, zero install) orviteston Node (peer dependency:bun add -d vitest). The exported names stay the same (test,describe,expect,beforeAll/afterAll/beforeEach/afterEach,mock,spyOn,jest) and the bun-style helpers are mapped onto vitest'svi.*equivalents so handler code stays identical.
v0.1.4May 2, 2026
client.options(path)for testing CORS preflight handlers and any otherOPTIONSroute. Mirrors the existingget/post/etc. surface and is also available on thewithHeader/withToken/withBasicAuthproxies.- Streaming endpoints no longer hang assertions. Pass
{ stream: true }to skip the body drain on SSE, long-poll, and download routes; status and headers come back immediately, and the rawResponseis exposed onres.rawif you want to read the stream yourself. res.assertError({ message, statusCode })transparently unwraps the framework's{ error: { ... } }envelope, so error assertions work the same whether the route returns a wrappedHttpExceptionpayload or a plain{ message, statusCode }body.
v0.1.3April 29, 2026
- Renamed
apiClient(baseUrl)toclient(baseUrl). Update imports:import { client } from '@tekir/testing'.
v0.1.2April 27, 2026
- The in-memory sqlite override now happens before
tekir()boots, so the database provider opens:memory:from the start. Previously the override mutated config after the connection was already open, which left tests pointing at the dev sqlite file. createTestApp()reads the app'sconfig/database.{ts,js,mjs}(when present) and clones it with sqlite paths swapped to:memory:, preserving any other connections and provider-specific options.
v0.1.1April 27, 2026
createTestApp()now picks an in-memory sqlite by default and runs pending migrations fromdatabase/migrationsautomatically. Tests no longer need a manual setup file withMigrationRunnerboilerplate.appRootis optional and defaults toprocess.cwd(). Pass a string (typicallyimport.meta.dir) only when tests live in a nested folder.- New options on
createTestApp:migrate(force-on/off auto-migration) andinMemoryDb(opt out of the sqlite override).
v0.1.0April 1, 2026
- Initial release