Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Jest Cheat Sheet

Jest Cheat Sheet

Back to Developer Tools
Updated 2026-04-29
Next Topic: Jupyter Notebooks Cheat Sheet

Jest is a JavaScript testing framework developed by Meta (formerly Facebook) that has become the industry standard for testing JavaScript applications, especially in the React ecosystem. It provides a zero-configuration setup with a built-in test runner, assertion library, mocking utilities, and code coverage tools—all in one package. Jest 30 (released June 2025) brought significant performance improvements—up to 37% faster runs and 77% lower memory usage—along with native .mts/.cts support, improved ESM handling, and new features like expect.arrayOf and jest.advanceTimersToNextFrame. The key mental model: Jest isolates each test file in its own VM context, so side effects, globals, and module caches never leak between files—but this isolation comes at a startup cost worth understanding when optimizing large suites.


What This Cheat Sheet Covers

This topic spans 24 focused tables and 184 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core Test StructureTable 2: Setup and Teardown HooksTable 3: Common MatchersTable 4: Asymmetric MatchersTable 5: Negation and ModifiersTable 6: Function and Mock MatchersTable 7: Error TestingTable 8: Snapshot TestingTable 9: Mocking FunctionsTable 10: Mock Data InspectionTable 11: Spying on MethodsTable 12: Mocking ModulesTable 13: Mock CleanupTable 14: Async TestingTable 15: Timer MocksTable 16: Code CoverageTable 17: Configuration OptionsTable 18: CLI OptionsTable 19: React Testing Library IntegrationTable 20: Snapshot Best PracticesTable 21: Global Test ConfigurationTable 22: Custom MatchersTable 23: Advanced Mocking PatternsTable 24: Common Gotchas

Table 1: Core Test Structure

FunctionExampleDescription
test / it
test('adds 1 + 2', () => { expect(1 + 2).toBe(3); })
• Defines a single test case
• it is a fully interchangeable alias.
describe
describe('Math', () => { test('add', () => {...}); });
• Groups related tests into a suite
• can be nested for hierarchical organization.
expect
expect(value).toBe(3)
• Creates an expectation object
• always paired with a matcher like toBe or toEqual.
test.each
test.each([[1,2,3],[2,3,5]])('adds %i+%i=%i',(a,b,e)=>{expect(a+b).toBe(e)})
• Parameterized testing—runs the same logic with different data
• reduces duplication.
test.skip
test.skip('not ready', () => {...})
• Skips a test
• temporarily disables without deleting. Also xit / xtest.
test.only
test.only('run this', () => {...})
• Runs only this test in the file
• all others skipped. Alias fit. Great for focused debugging.

More in Developer Tools

  • IntelliJ IDEA Cheat Sheet
  • Jupyter Notebooks Cheat Sheet
  • AI-LLM Code Generation Cheat Sheet
  • Docker Desktop for Developers Cheat Sheet
  • Notepad++ Cheat Sheet
  • Sublime Text Cheat Sheet
View all 55 topics in Developer Tools