question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request for mocks for unit-tests

See original GitHub issue

🚀 Feature request

Could we get mocks like how you’ve provided it in your universal package? Ref - link

import '@ng-web-apis/universal/mocks';

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
waterpleacommented, Jun 1, 2021

This library is just a library of token so you make your apps without any direct access to global entities, because they might not be available in some environments. Universal package is the package of substitutes for those tokens for server side which also might work in other environments where they are missing. For example jest testing is a lot like universal as it is also emulated DOM. Is Jasmine/Karma you don’t need mocks, because tokens are available as is. But you can easily mock them with spies etc. in unit tests.

1reaction
waterpleacommented, Jun 2, 2021

When you configure TestBed you can add to providers something like this:

{
  provide: WINDOW,
  useValue: { 
    matchMedia(query: string): boolean {
      return query === '(min-width: 400px)';
    }
  }
}

for example, if your code depends on screen size by running window.matchMedia and you want to test particular configuration

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I mock requests and the response? - python
This is how you can do it (you can run this file as-is): import requests import unittest from unittest import mock # This...
Read more >
Mocking around with Python and Unittest - DevelopersIO
With mock module we can specify a value that above requests.post method will return. Here we have a test where we call my_module.call_api ......
Read more >
How to Mock the requests Module in Python
In this tutorial, you'll learn how to mock the requests module in Python to test an API call using the unittest module.
Read more >
Mocking in Unit Tests - Code With Engineering Playbook
If there is more logic and a unit test with mocking is required, you should apply this principle by verifying mock calls and...
Read more >
Mock http request in C# for Unit testing | by Nitesh Singhal
A short guide to mock http calls in Unit Testing in C# or .NET ... Many time we call external rest API's from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found