Comments (5)
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.
from ng-web-apis.
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
from ng-web-apis.
Hey 👋 You mean like for testing with jest? I believe you can already just use mocks from universal, as well as tokens from it. Please let me know if that works for you.
from ng-web-apis.
For Jasmine/Karma. But will check with the mocks from universal.
But the mocks and tokens can be taken from universal, why maintain 2 repos with the same functionalities?
from ng-web-apis.
@waterplea Do you have an example of how these tokens can be mocked in Jasmine/Karma unit tests?
from ng-web-apis.
Related Issues (20)
- [FEATURE] Installation guide in README HOT 1
- Provide GitHub releases HOT 3
- [FEATURE] Request for navigator.mediaDevices
- [FEATURE] Create screen token HOT 1
- [BUG] PAGE_VISIBILITY does not emit to late subscribers
- [BUG] TypeError: this.window.scrollTo is not a function HOT 1
- [BUG] - requestAnimationFrame is not a function HOT 4
- Migration
- [FEATURE] Add support to Notification API and PushManager API
- [BUG] Storage not working
- [UIKIT-6419] Add job for publish ng-web-apis in Tinkoff
- [BUG] Cannot find name 'SpeechRecognition' HOT 1
- 🚀 - Add view transition
- 🚀 - More features for `@ng-web-apis/notification` package
- 🐞 - TS2552: Cannot find name 'PushPermissionState'. Did you mean 'PermissionState'?
- Cannot find 'Type<SpeechRecognition> 🐞 HOT 2
- 🤖 - Upgrade to Angular 16
- 🚀 - Pass intersection observer to observer handler HOT 1
- 🐞 - MutationObserver is not defined HOT 1
- 🐞 - Module not found: Error: Can't resolve 'perf_hooks' @ng-web-apis/universal on Angular 17 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-web-apis.