Answer: You can ask Copilot Chat to generate a mock object for a service so unit tests don't depend on external services; the example prompt is "Create a unit test to ensure the service is called correctly. Mock the service object." Status: Confirmed Entry: tool/github-copilot/features/create-mock-objects-abstract-layers Revision: 3 Digest: sha256:90fc1dfa0cc4cb74 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:33:44Z Last changed: 2026-11-18T13:12:27Z (Mocking approach: — → vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } }));) Last verified: 2026-11-20T13:15:53Z Next check: 2026-11-21T13:15:53Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Example prompt | Create a unit test to ensure the service is called correctly. Mock the service object. | [1] | 2026-11-20 Capability | Copilot Chat can help you generate the code you need to create these mock objects. | [1] | 2026-11-20 Test runner assumption | vitest | [1] | 2026-11-20 Mocking approach | vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } })); | [1] | 2026-11-20 Sources: [1] GitHub. "Creating mock objects to abstract layers - GitHub Docs". https://docs.github.com/en/copilot/tutorials/copilot-cookbook/testing-code/create-mock-objects Role: primary. Accessed: 2026-11-20T13:15:53Z Quote: "Create a unit test to ensure the service is called correctly. Mock the service object." (Supports: Example prompt) Quote: "Copilot Chat can help you generate the code you need to create these mock objects." (Supports: Capability) Quote: "This example assumes you are using vitest for your tests, but will work with other test runners." (Supports: Test runner assumption) Quote: "vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } }));" (Supports: Mocking approach) Snapshot SHA-256: 9a024fffe774e8904e9ede160720003bed32ebd98cb36ef3e04e10d21c2c54e3 (captured 2026-11-18T13:12:27Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-18T13:12:27Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:15:53Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:15:53Z Last attempt: 2026-11-20T13:15:53Z Notes and limitations: Extracted automatically from a single official source (section "Creating mock objects to abstract layers"). Related: https://latestn.com/tool/github-copilot/features/create-plugin How do I create a plugin for GitHub Copilot CLI? https://latestn.com/tool/github-copilot/features/create-plugin-marketplace-repository How do I create a plugin marketplace repository for GitHub Copilot? https://latestn.com/tool/github-copilot/features/create-pr-summaries How do I create pull request summaries with GitHub Copilot? https://latestn.com/tool/github-copilot/features/create-diagrams-with-copilot How do I use GitHub Copilot to create diagrams? https://latestn.com/tool/github-copilot/features/create-end-to-end-tests How do I use GitHub Copilot to create end-to-end tests for a webpage? https://latestn.com/tool/github-copilot/features/create-mock-objects How do I use GitHub Copilot to create mock objects that abstract layers in my tests? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-18T13:12:27Z | changed | Mocking approach: — → vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } })); | [1] 2026-11-18T13:12:27Z | changed | Test runner assumption: — → vitest | [1] 2026-11-18T13:12:27Z | changed | Capability: — → Copilot Chat can help you generate the code you need to create these mock objects. | [1] 2026-11-18T13:12:27Z | changed | Example prompt: — → Create a unit test to ensure the service is called correctly. Mock the service object. | [1] 2026-11-18T13:12:27Z | changed | existing test option: #file: path/to/test-file.js → — | [1] 2026-11-18T13:12:27Z | changed | test runner assumption: vitest → — | [1] 2026-11-18T13:12:27Z | changed | mock code example: vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } })); → — | [1] 2026-11-18T13:12:27Z | changed | capability: Copilot Chat can help you generate the code you need to create these mock objects. → — | [1] 2026-11-18T13:12:27Z | changed | purpose: create mock objects that abstract layers of your application → — | [1] 2026-11-18T13:12:27Z | changed | example prompt: Create a unit test to ensure the service is called correctly. Mock the service object. → — | [1] 2026-11-17T13:36:04Z | changed | existing test option: — → #file: path/to/test-file.js | [1] 2026-11-17T13:36:04Z | changed | test runner assumption: — → vitest | [1] 2026-11-17T13:36:04Z | changed | mock code example: — → vi. mock ( './service' , () => ({ default : { getRunner : vi. fn () } })); | [1] 2026-11-17T13:36:04Z | changed | purpose: — → create mock objects that abstract layers of your application | [1] 2026-11-17T13:36:04Z | changed | model file option: #file: path/to/test-file.js → — | [1] 2026-11-17T13:36:04Z | changed | test runner: vitest → — | [1] 2026-11-17T13:36:04Z | changed | mock approach: Mock the entire service module → — | [1] 2026-11-13T03:33:44Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/github-copilot/features/create-mock-objects-abstract-layers/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/github-copilot/features/create-mock-objects-abstract-layers POST: https://latestn.com/dispute/tool/github-copilot/features/create-mock-objects-abstract-layers with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/github-copilot/features/create-mock-objects-abstract-layers?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I use GitHub Copilot to create mock objects that abstract layers in my code? Revision 3, last verified 2026-11-20T13:15:53Z. https://latestn.com/tool/github-copilot/features/create-mock-objects-abstract-layers (accessed 2026-11-21T09:52:55Z). @misc{LatestN_tool_github_copilot_features_create_mock_objects_abstract_layers_r3, title = {How do I use GitHub Copilot to create mock objects that abstract layers in my code?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/github-copilot/features/create-mock-objects-abstract-layers}}, note = {Revision 3; digest sha256:90fc1dfa0cc4cb74; last verified 2026-11-20T13:15:53Z; accessed 2026-11-21T09:52:55Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/github-copilot/features/create-mock-objects-abstract-layers