typescript-testing

Implement TypeScript and JavaScript tests using Bun's native test runner.

Updated Apr 11, 2023
One-click install
npx skills add https://github.com/salverius-tech/dotfiles --skill typescript-testing-salverius-tech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-testing
Source: https://github.com/salverius-tech/dotfiles/tree/main/home/dot_claude/skills/typescript-testing
Command: npx skills add https://github.com/salverius-tech/dotfiles --skill typescript-testing-salverius-tech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance on leveraging Bun's built-in test runner for efficient and effective testing of TypeScript and JavaScript applications, ensuring robust code quality.

Core Features & Use Cases

  • Bun Test Runner: Utilize bun test for all testing needs, avoiding other runners like Jest or Vitest.
  • Test Structure & API: Learn how to organize tests with describe and it, and use Bun's assertion API.
  • Mocking & Async: Master mocking dependencies and handling asynchronous operations within tests.
  • Integration & Type Testing: Understand how to test APIs, databases, and TypeScript types.
  • Use Case: You are developing a new feature in a Bun project and need to write unit tests for your utility functions, ensuring they behave as expected under various conditions.

Quick Start

Run your tests using the command bun test.

Frequently Asked Questions about typescript-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run TypeScript unit tests using Bun's native test runner?

You can run TypeScript unit tests using Bun's native test runner by executing the `bun test` command. It provides built-in assertion APIs and structure utilities like `describe` and `it` without requiring external runners.

Can I use Jest or Vitest for integration testing in a Bun project?

Jest or Vitest are not recommended for integration testing in a Bun project. You should exclusively use `bun test` to handle integration testing scenarios, including APIs and databases, ensuring native compatibility.

What is the best way to mock dependencies in TypeScript tests with Bun?

The best way to mock dependencies in TypeScript tests with Bun is by utilizing the built-in mocking strategies provided by the `bun test` runner. This allows you to effectively isolate modules and handle asynchronous operations.

Does Bun's test runner support type safety checks for TypeScript?

Yes, Bun's test runner supports type safety checks for TypeScript. You can verify your TypeScript types directly within your test suite using `bun test` to ensure robust code quality and type integrity.

How do I organize integration tests and async operations in Bun?

You organize integration tests and async operations in Bun by using `describe` and `it` blocks to structure your tests. Bun's native test runner provides specific patterns for handling asynchronous testing and integration scenarios effectively.