I am writing a unit test for a pubsub component in my service. My directory structure looks like this: The file publish_to_topic.ts looks like this And is called by publish_event.ts like so: Lastly in my test file publish_event.test.ts, I set up a mock: Alas, my test fails: Can anyone explain where I’ve…
Tag: javascript
Grid display separates when viewed fullscreen
I’m having trouble understanding whats going on with a grid I created. I made some code for a grid via javascript that changes the cell color when the mousepointer passes over it, however whenever I view this grid in a fullscreen window the view of the grid changes to four separate columns. This only ha…
How to make content delay using CSS and Jquery
I am attempting to create a page where the content on the screen appears 3 seconds after the page loads. By the other posts I have seen on this website, I attempted the scripting below, though with no success (Everything appears at the same time). First is the section I am attempting to delay, then is the who…
How to display build version in React/webpack app
I need to version every build and display it in app. I’ve tried to use this tutorial but it didn’t work for me https://dmitriy-comarov.medium.com/app-version-from-package-json-with-react-and-webpack-84097bd3f4f9 Is there any way to make it work? Answer You still can follow this tutorial above but …
How good is to apply React Context API for all screens
Currently I have four contexts that wrap all my routes (as shown bellow) so that I don’t have lost providers all around my app screens and components. As far as I know, when I modify the value of a context variable, every component that uses it will update too, what can lead to memory problems, but my q…
jQuery: push checked checkboxes to array
I am trying to add to array checked checkboxes, but the array comes up empty, what am I doing wrong on my script? Answer Fix
How can I use useEffect and store an array in Reactnative?
I have data from redux called targetFarm. targetFarm.children contains these array object data. I want to put data in targetFarm.children into gyetong using useEffect and setgyeTong hooks. As an array object value like below But with my code it only takes one array. How can i fix my code? Answer For your info…
PWA Building Best Practices: Determinsitic Updates Android
I just built my first PWA from an existing website, using PWABUILDER and not able to figure out how to handle updates after installs. Currently only deterministic way of updating the PWA, is by uninstall & reinstalling. As per web.dev, it’s very ambiguous: Chrome Android checks every 24 hour to seek…
PDFJS cannot use a local worker file
I’m adding the workerSource pdfjsLib.GlobalWorkerOptions.workerSrc = ‘./pdf.worker.js’; but still showing this warning in the console Setting up fake worker. It works only when referencing the original file in github Answer I had the issue because I already had an instance of the pdfWorker c…
Javascript display the last 3 numbers after the dot fixed(3) not working
I have a number which looks number this: This number changes all the time. So I’m doing this: This is displaying 800.600 … I need it to display the last 3 like: How can I do this? Answer You can convert to string and do your manipulations. Please note we are loosing the right most digit due to lim…