मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग75k · #2941

mock-best-practices

यह क्या करती है

यह स्किल देखती है कि टेस्ट फ़ाइल mocks का इस्तेमाल कैसे करती है, यानी कोड के बाहरी हिस्सों की जगह लेने वाले स्टैंड-इन। यह उन डेवलपर्स के लिए है जो ऐसे टेस्ट चाहते हैं जो असली समस्याएँ पकड़ें, न कि सिर्फ़ पास हो जाएँ।

कब इस्तेमाल करें

  • ✓जब आप एजेंट से टेस्ट फ़ाइल में mocks के इस्तेमाल की समीक्षा चाहते हैं।
  • ✓जब टेस्ट पास होते हैं पर असली ऐप टूटती है, और आपको शक है कि बहुत ज़्यादा mock हो रहा है।
  • ✓जब आप नए टेस्ट लिख रहे हैं और जानना चाहते हैं कि किसे mock करें और किसे असली रखें।

Skill का लिंक

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mock-best-practices/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mock-best-practices/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे टेस्ट पास होते हैं पर ऐप फिर भी टूटती है। क्या आप जाँच सकते हैं कि मैं बहुत ज़्यादा mock तो नहीं कर रहा?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट टेस्ट फ़ाइल पढ़ता है और ऐसे mocks खोजता है जो बिज़नेस लॉजिक छिपाते हैं, जहाँ सफ़ाई नहीं होती, और ऐसे टेस्ट जो आंतरिक विवरण जाँचते हैं। फिर वह ज़रूरी न होने वाले mocks हटाने और सही स्तर पर mock करने का सुझाव देता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Follow mocking best practices

Proper mocking isolates units under test while keeping tests realistic—over-mocking creates false confidence when tests pass but production breaks.

Quick Reference

  • Mock external dependencies (APIs, databases, file system), not business logic
  • Always clean up mocks with jest.restoreAllMocks() in afterEach
  • Use MSW for realistic API mocking without coupling to implementation
  • Test behavior and outputs, not internal implementation details

Check

Review this test file for mocking patterns, checking for over-mocking, missing mock cleanup, and proper mock implementation.

Fix

Improve mocking strategy by removing unnecessary mocks, adding proper cleanup, and mocking at the right level of abstraction.

Explain

Explain mocking best practices including when to mock, what to mock, and common mocking pitfalls.

Code Review

Review tests, CI workflows, and enforcement points related to Follow mocking best practices. Flag exact gaps where the rule is not automatically verified or where failures do not block regressions.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/testing/mock-best-practices

अक्सर पूछे जाने वाले सवाल

किसे mock करना चाहिए?

स्किल कहती है कि APIs, databases और file system जैसी बाहरी निर्भरताओं को mock करें, बिज़नेस लॉजिक को नहीं।

MSW क्या है?

यह यथार्थवादी API mocking का टूल है, जो इस पर निर्भर नहीं करता कि आपका कोड API को कैसे कॉल करता है।

mocks की सफ़ाई क्यों ज़रूरी है?

टेस्ट के बीच छूटे mocks नतीजे बदल सकते हैं और फ़ेल होने के कारण समझना मुश्किल बना सकते हैं।

जानकारी

लेखक का मूल विवरण

Use when reviewing CI coverage, automated checks, or test strategy related to Follow mocking best practices. Focus on whether the rule is continuously verified, not just documented.

repo: thedaviddias/Front-End-Checklist

लोकप्रियता

GitHub स्टार
75k
रैंकिंग में स्थान
#2941
लाइसेंस
MIT
अपडेट की गई
31/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills