Testing Frameworks Used by Insomnia: Vitest and Playwright Configuration Guide
Insomnia uses Vitest for unit and integration testing across its npm workspaces and Playwright for end-to-end smoke testing, as configured in the respective package.json files throughout the Kong/insomnia monorepo.
The Kong/insomnia repository relies on a dual-framework testing strategy to ensure code quality across its Electron-based API client. According to the package.json manifests distributed throughout the monorepo, the project leverages Vitest for fast, Vite-native unit testing and Playwright for browser-level end-to-end validation.
Vitest: Unit and Integration Testing Across Workspaces
Vitest serves as the primary testing framework for the majority of Insomnia’s packages. As declared in multiple package.json files, the test script consistently invokes vitest run to execute unit and integration tests with TypeScript support out of the box.
Core Packages Using Vitest
The following workspaces declare Vitest in their testing scripts:
packages/insomnia/package.json(line 35):"test": "vitest run"packages/insomnia-testing/package.json(line 17):"test": "vitest run"packages/insomnia-scripting-environment/package.json(line 10):"test": "vitest run"packages/insomnia-data/package.json(line 34):"test": "vitest run"packages/insomnia-api/package.json(line 26):"test": "vitest run"packages/insomnia-analytics/package.json(line 31):"test": "vitest run"
Additionally, packages/insomnia-inso/package.json (lines 34-37) defines multiple Vitest-based scripts: test:unit, test:unit:color, test:bundle, and test:binary, enabling comprehensive CLI testing alongside standard unit validation.
Example Vitest Unit Test
Test files throughout the codebase follow Vitest’s Jest-compatible API. A typical unit test located in packages/insomnia-testing/__tests__/example.test.ts demonstrates the framework’s syntax:
import { describe, expect, test } from 'vitest';
import { sum } from '../src/common/math';
describe('sum()', () => {
test('adds two numbers', () => {
expect(sum(2, 3)).toBe(5);
});
});
Playwright: End-to-End Smoke Testing
While Vitest handles isolated unit tests, Playwright manages full-application end-to-end testing within the insomnia-smoke-test workspace. This framework provides browser-level automation to verify the Electron application’s behavior under realistic conditions.
E2E Configuration in insomnia-smoke-test
The packages/insomnia-smoke-test/package.json (line 23) declares Playwright as the test runner via the script "test": "tests". This configuration targets the packaged Electron application, verifying window launches, UI interactions, and network request flows through actual browser automation.
Example Playwright Smoke Test
Smoke tests located in packages/insomnia-smoke-test/tests/app.spec.ts utilize Playwright’s test API to validate the Electron application:
import { test, expect } from '@playwright/test';
test('launches Insomnia and shows the main window', async ({ page }) => {
await page.goto('http://localhost:3000'); // Electron dev server URL
const title = await page.title();
expect(title).toContain('Insomnia');
});
Running Tests Across the Monorepo
The root package.json (line 32) orchestrates testing across all workspaces through the script "test": "npm run test --workspaces --if-present". This command delegates to individual workspace scripts, ensuring both Vitest and Playwright execute in their respective contexts.
To run the full test suite locally:
- Execute
npm run testfrom the repository root to trigger all workspace tests - Run
npm run test:devortest:buildto initiate Playwright smoke tests against development or production builds
Summary
- Vitest serves as the primary unit and integration testing framework across seven core packages, including
insomnia,insomnia-testing, andinsomnia-inso. - Playwright handles end-to-end smoke testing exclusively within the
insomnia-smoke-testworkspace. - Test scripts in individual
package.jsonfiles consistently use"vitest run"for unit tests and Playwright’s test runner for E2E validation. - The root
package.jsonorchestrates execution across the monorepo using npm workspaces.
Frequently Asked Questions
What testing framework does Insomnia use for unit tests?
Insomnia uses Vitest for all unit and integration testing. As declared in packages/insomnia/package.json and six other workspace manifests, the test script executes vitest run to leverage the framework’s Vite-native performance and Jest-compatible API.
How does Insomnia handle end-to-end testing?
End-to-end testing is implemented using Playwright in the packages/insomnia-smoke-test directory. This framework automates the Electron application to verify UI behavior, window management, and network flows through browser-level interactions.
Can I run all Insomnia tests from the root directory?
Yes. The root package.json (line 32) contains the script "test": "npm run test --workspaces --if-present", which automatically executes test scripts across all npm workspaces, including both Vitest unit tests and Playwright smoke tests.
Why does Insomnia use two different testing frameworks?
Insomnia employs Vitest for fast, isolated unit tests that validate individual modules without launching the full application, and Playwright for realistic end-to-end scenarios that require the complete Electron context. This dual-framework approach provides comprehensive coverage across the testing pyramid without compromising execution speed during development.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →