Vyriy Jest Config

@vyriy/jest-config is a shared Jest configuration package for Vyriy projects.

The goal of this package is to keep test setup consistent across packages, examples, applications, and libraries. Instead of copying the same Jest configuration into every project, each package can extend the shared config and focus only on its own source code and tests.

This example shows a small TypeScript module, a Jest test file, and the result of running the test suite with coverage enabled.

Installation

Install the shared TypeScript config, the shared Jest config, and Jest:

yarn add @vyriy/typescript-config @vyriy/jest-config jest

TypeScript config

Create a tsconfig.json file:

{
  "extends": "@vyriy/typescript-config/index.json",
  "include": ["*.ts"]
}

The project extends the shared Vyriy TypeScript configuration and includes TypeScript files from the current directory.

Jest config

Create a jest.config.mjs file:

export { default } from '@vyriy/jest-config';

This keeps the local Jest setup minimal. The project imports the shared configuration and can override it later only when package-specific behavior is needed.

Source file

Create an index.ts file:

export type User = {
  id: number;
  name: string;
  email: string;
  isActive: boolean;
};

export type FormatUser = (user: User) => string;

export const formatUser: FormatUser = (user) => {
  const status = user.isActive ? 'active' : 'inactive';

  return `${user.name} <${user.email}> is ${status}`;
};

The module exports a User type, a FormatUser function type, and a formatUser function.

The implementation is intentionally small, but it is enough to show that Jest can run TypeScript tests and collect coverage from the source file.

Test file

Create an index.test.ts file:

import { formatUser, type User } from './index';

describe('formatUser', () => {
  it('formats active user', () => {
    const user: User = {
      id: 1,
      name: 'Evheniy',
      email: 'evheniy@example.com',
      isActive: true,
    };

    expect(formatUser(user)).toBe('Evheniy <evheniy@example.com> is active');
  });

  it('formats inactive user', () => {
    const user: User = {
      id: 2,
      name: 'Anna',
      email: 'anna@example.com',
      isActive: false,
    };

    expect(formatUser(user)).toBe('Anna <anna@example.com> is inactive');
  });
});

The test file checks two branches of the formatUser function:

  • active user;
  • inactive user.

This makes the example useful not only for checking that Jest works, but also for validating branch coverage.

Run tests

Run Jest:

npx jest

Output:

 PASS  ./index.test.ts
  formatUser
    ✓ formats active user (1 ms)
    ✓ formats inactive user

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |
 index.ts |     100 |      100 |     100 |     100 |
----------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : 100% ( 14/14 )
Branches     : 100% ( 3/3 )
Functions    : 100% ( 1/1 )
Lines        : 100% ( 14/14 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.831 s, estimated 1 s
Ran all test suites.

Why shared Jest config?

A shared Jest config helps keep testing predictable across many packages.

For Vyriy projects, this is useful because packages are expected to stay small, focused, and easy to validate. Each package can have its own source file, its own test file, and a shared baseline for running tests in the same way everywhere.

This keeps the testing setup calm, reusable, and explicit.

Documentation

See the Jest config API documentation.