<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Divya Sonara on Medium]]></title>
        <description><![CDATA[Stories by Divya Sonara on Medium]]></description>
        <link>https://medium.com/@divya.sonara?source=rss-2a23ab991178------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Eojj0JSkAzj7WJje</url>
            <title>Stories by Divya Sonara on Medium</title>
            <link>https://medium.com/@divya.sonara?source=rss-2a23ab991178------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:48:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@divya.sonara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Vue.js Testing with Cypress: A Beginner’s Handbook]]></title>
            <link>https://medium.com/simform-engineering/vue-js-testing-with-cypress-a-beginners-handbook-93c793ba74ec?source=rss-2a23ab991178------2</link>
            <guid isPermaLink="false">https://medium.com/p/93c793ba74ec</guid>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[vue-testing-library]]></category>
            <dc:creator><![CDATA[Divya Sonara]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 05:29:52 GMT</pubDate>
            <atom:updated>2024-03-01T05:29:52.112Z</atom:updated>
            <content:encoded><![CDATA[<p><em>As the web has changed over time, testing methods must also change!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0xrww8veBx2fUmsxN2Jlw.png" /></figure><p>In this blog, we’ll explore the complexities and solutions of testing in the contemporary web landscape. From timing issues to asynchronous JavaScript, we’ll navigate the hurdles faced with traditional tools like Selenium and reveal the game-changing capabilities of Cypress.</p><p>Come along as we explore the distinction of web testing and prepare the Vue.js environment for smooth testing experiences.</p><h3>Difficulties with modern web testing</h3><p><strong>Timing issues:</strong> Timing can be critical in modern web applications, especially when waiting for elements to appear or for certain actions to be completed. Selenium’s built-in wait mechanisms may not always be sufficient, leading to flaky tests.</p><p><strong>Asynchronous JavaScript:</strong> Many modern web applications heavily rely on asynchronous JavaScript requests to fetch data or update the UI. Selenium may struggle to synchronize with these asynchronous actions, leading to timing-related test failures.</p><p><strong>Maintenance overhead:</strong> Modern web applications are frequently updated with new features and changes to the UI. Maintaining Selenium tests to keep up with these changes can be time-consuming, especially if the tests are brittle and prone to failure.</p><p><strong>Complex interactions:</strong> Some interactions in modern web applications, such as drag-and-drop, hover effects, or gestures, can be challenging to automate with Selenium alone. Additional tools or custom implementations may be required to simulate these interactions effectively.</p><p><strong>Cross-Origin Resource Sharing (CORS):</strong> When testing applications that make requests to different domains, CORS policies may restrict Selenium’s ability to interact with those resources, leading to test failures.<br><br>These are only a few of the issues that arise with selenium. For the past ten years, Selenium has been a major participant in end-to-end web application testing. However, the modern web differs; we now use Cypress to get around Selemium’s drawbacks.</p><h3>Why Cypress?</h3><p>Cypress is a JavaScript-based end-to-end testing framework that stands apart from traditional Selenium-based solutions. It leverages Mocha, a robust JavaScript test framework, and Chai, a versatile assertion library for node in the browser, enhancing testing capabilities.</p><p>Brian Mann, the creator of Cypress.io, identified common testing challenges and addressed them with Cypress. Noteworthy features include:</p><p><strong>Time travel: </strong>Time travel takes snapshots as your test run. Simply hover over commands in the command log to see what happened to each step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHiQplEhG7tmOCcLVTk6Aw.gif" /><figcaption>credit: <a href="https://www.cypress.io/">Cypress.io</a></figcaption></figure><p><strong>Automatic waiting:</strong> Cypress intelligently waits for various DOM conditions, eliminating the need for explicit or implicit wait statements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDeC0N_ML2eRuzzv650ZOw.gif" /><figcaption>credit: <a href="https://www.cypress.io/">Cypress.io</a></figcaption></figure><p><strong>Real-time reloads: </strong>When saving a test file, Cypress anticipates the next run and automatically triggers it, streamlining the testing process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wYimNckYvY94z1MIhCSoA.gif" /><figcaption>credit: <a href="https://www.cypress.io/">Cypress.io</a></figcaption></figure><p><strong>Debuggability</strong>: Cypress facilitates direct debugging of the application under test through Chrome DevTools. It offers clear error messages and helpful suggestions for resolving issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDBHVSjks4Y0rdszJ5g_uw.gif" /><figcaption>credit: <a href="https://www.cypress.io/">Cypress.io</a></figcaption></figure><p><strong>Here are additional benefits provided by Cypress:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28zNs8VyStf6zLjJkmXHlg.png" /></figure><p>Before we start testing Vue applications, let’s see how the folders are arranged in Cypress:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XfpcOZ7csqFzxKxoz7qbFQ.png" /><figcaption>credit: <a href="https://www.youtube.com/watch?v=1ZsD0jV3v0U&amp;list=PLUDwpEzHYYLvA7QFkC1C0y0pDPqYS56iU&amp;index=6">SDET-QA</a></figcaption></figure><p><strong>Downloads:</strong> This directory contains files that Cypress downloads during test runs, if any.</p><p><strong>e2e: </strong>This directory usually holds your actual end-to-end test files. These files are written using Cypress’s testing syntax (e.g., using describe, it, etc.).</p><p><strong>fixtures: </strong>Fixtures are external pieces of static data that can be used within tests. This directory often contains files like JSON, images, or other static data that your tests might need.</p><p><strong>screenshots:</strong> This folder stores screenshots taken during test runs, which can be useful for debugging or documentation purposes.</p><p><strong>support:</strong> The Support folder contains support files for your Cypress tests. These files might include custom commands, custom Cypress configuration, or other utility functions that your tests might need.</p><p><strong>videos:</strong> If configured, this directory stores videos of your test runs, which can be useful for reviewing test execution.</p><p><strong>node_modules: </strong>This directory contains all the dependencies installed for Cypress, as well as any other dependencies for your Vue project.</p><p>This folder is managed by npm or yarn and contains all the packages needed to run your project and tests.</p><p><strong>cypress.config.js:</strong> This file is the Cypress configuration file. It allows you to configure various aspects of your Cypress setup, such as file paths, browser preferences, test environment settings, and more.</p><h3>Testing a Vue.js application using Cypress</h3><p>Now, let’s integrate Cypress and observe how it operates within a Vue.js application.</p><p><strong>Environment setup</strong></p><p>Installing Cypress is a fairly simple task. The only thing you need is <a href="https://nodejs.org/"><em>node.js</em></a><em> </em>installed on your machine.</p><p>To integrate Cypress into an existing Vue project, execute the following command:</p><p><em>npm install cypress — save-dev</em></p><p>However, for this tutorial, we’ll be integrating Cypress during the creation of a new Vue project.</p><p><strong>Integration during project creation:</strong></p><ul><li>Create a New Project by following the command: npm init vue@latest</li><li>The command will prompt you to answer a series of questions; answer them with the configuration shown below for end-to-end testing:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*K6BbiBH6-UV57EeXzPQvCQ.png" /></figure><p>You should now find a newly created directory named TODO. Execute the subsequent commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*wyfG8C044-qSbRKKJjEokA.png" /></figure><p>Once you’ve done all the commands, the TODOdirectory will look as shown below, and the app will work on the usual port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ga4hhgEG_E7M2jHHCDfLJg.jpeg" /></figure><p>I’ve included two new pages in the Vue project provided earlier: one for managing TODOs and another for a counter. We’ll use Cypress to test both the pages and their components. But first, let’s look at how the app runs and the basic Vue code it’s built on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*uWaFzx7otE4JAYlsgfBskg.gif" /></figure><p>GitHub Repository: <a href="https://github.com/divyasonaraa/cypress-with-vue-todo-app">TODO-APP</a></p><p><strong><em>Experience the live demonstration:</em></strong><em> </em><a href="https://cypress-with-vue-todo-app.netlify.app/"><em>TODO-APP</em></a></p><h3>Writing the first E2E tests</h3><p>To begin testing, we’ll create the first end-to-end (e2e) test case for both TODO and counter pages. We’ll accomplish this by updating the example.cy.js file as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d63a366f39fed7a947b020cb6eebd470/href">https://medium.com/media/d63a366f39fed7a947b020cb6eebd470/href</a></iframe><blockquote><strong>Note:</strong></blockquote><blockquote>The screenshotOptions object is defined with an overwrite property set to true will save screenshots inside screenshot folder.</blockquote><blockquote>Selectors used to identify elements on the page are stored in a separate file (<em>../fixtures/selectors.js</em>).</blockquote><blockquote>Constants such as paths and literals are stored in another file (<em>../fixtures/constants.js</em>).</blockquote><p>Let’s analyze the given code step by step.</p><h3><strong>1. Test Suite — My ToDo app</strong></h3><p>The descibe() function starts a test suite labeled <strong>My ToDo App</strong>.</p><p>The beforeEach() function is used to visit the homepage (`/`) before each test case within this suite.</p><p><strong>Test Case 1: The user can see the home page</strong></p><ul><li>It verifies that the homepage contains an <strong><em>h1</em></strong> element with the text <em>“You did it!”.</em></li><li>Then, it takes a full-page screenshot using cy.argosScreenshot().</li></ul><p><strong>Test Case 2: It should add a new ToDo item</strong></p><ul><li>It types into the input field with the name “<em>todo</em>,” adds a todo item by clicking the “<em>Add”</em> button, and asserts that the item is added to the list.</li></ul><p><strong>Test Case 3: It should mark a ToDo item as done</strong></p><ul><li>It adds a new todo item, checks the checkbox for marking it as done, and asserts that the text decoration of the todo item changes to have a line-through style.</li></ul><p><strong>Test Case 4: It should delete a task</strong></p><ul><li>It adds a new todo task, then finds and clicks the delete button associated with it, and verifies that the task has been removed from the list.</li></ul><h3><strong>2. Test Suite — Navigate to counter page</strong></h3><p>This suite navigates to the counter page.</p><p>The beforeEach() function ensures that the homepage is visited before each test in this suite.</p><ol><li><strong>Test Case: The user can go to the counter pag</strong>e</li></ol><ul><li>It clicks on the counter navigation button, ensures the URL contains the counter path, and verifies the presence of text related to the counter.</li></ul><h3><strong>3. Test Suite — Counter page</strong></h3><p>This suite focuses on testing the counter page.</p><p>The beforeEach() function ensures that the counter page is visited before each test in this suite.</p><p><strong>Test Case 1: The user can increment once the counter</strong></p><ul><li>It clicks on the button labeled “+1” and verifies that the counter is incremented by 1.</li></ul><p><strong>Test Case 2: The user can increment +2 the counter</strong></p><ul><li>It clicks twice on the “+1” button and verifies that the counter is incremented by 2.</li><li>It also takes a screenshot after the increment.</li></ul><p><strong>Test Case 3: The user can reset the counter</strong></p><ul><li>It clicks the “Reset” button and verifies that the counter is reset to 0.</li><li>It also takes a screenshot after the reset.</li></ul><h3>Execute the test scenario</h3><p>To execute the test case described above, use the following command:</p><pre>npm run test:e2e:dev</pre><p>Once you run the command above, you’ll be prompted to choose which web browser you want to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9hMrejXgflR6w194OnSRQ.png" /></figure><p>Pick a browser, and then you’ll be able to see it working, as shown in the output below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79Byps6UmNIpLCGzEBabEA.gif" /><figcaption>E2E Testcase result</figcaption></figure><h4>Conclusion</h4><p>These tests cover a ToDo application and a counter page, thoroughly verifying their functionalities and interactions. Leveraging Cypress’s powerful `<strong>cy</strong>` commands, we interact with elements on the web pages and assert their behaviors.</p><p>As you begin testing your VueJS application with Cypress, stay tuned for more updates and insights. Next, we will talk about writing effective E2E test cases, component testing, debugging common issues, and optimizing our testing strategy for maximum efficiency.</p><p>Happy testing!</p><blockquote><strong>For more updates on the latest development trends, follow the </strong><a href="https://medium.com/simform-engineering"><strong>Simform Engineering</strong></a><strong> blog.</strong></blockquote><blockquote><strong>Follow Us: </strong><a href="https://twitter.com/simform"><strong>Twitter</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/simform/"><strong>LinkedIn</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93c793ba74ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/vue-js-testing-with-cypress-a-beginners-handbook-93c793ba74ec">Vue.js Testing with Cypress: A Beginner’s Handbook</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the Future with Quasar: A Vue.js Framework Revolution]]></title>
            <link>https://medium.com/simform-engineering/building-the-future-with-quasar-a-vue-js-framework-revolution-74b09723a91d?source=rss-2a23ab991178------2</link>
            <guid isPermaLink="false">https://medium.com/p/74b09723a91d</guid>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[vue-3]]></category>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[quasarframework]]></category>
            <dc:creator><![CDATA[Divya Sonara]]></dc:creator>
            <pubDate>Fri, 01 Dec 2023 05:17:20 GMT</pubDate>
            <atom:updated>2023-12-01T05:17:20.428Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Explore</em> <em>the simplicity and power of building PWAs with the Quasar framework.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cF0lKv9Gb_NfEKDOwIDyIQ.png" /></figure><p>If you’re here, you’re likely familiar with Quasar, the robust Vue.js framework. If not, no problem at all! You’re about to learn something new.</p><p>Here are some types of applications that can be created using Quasar:</p><p>1. Progressive Web Apps (PWAs) <br>2. Single Page Applications (SPAs) <br>3. Cross-Platform Applications <br>4. Mobile Applications<br>5. Server-Side Rendered (SSR) Applications <br>6. Hybrid Applications</p><p>In this blog post, I’ll walk you through how you can leverage Quasar to build Progressive Web Apps easily and efficiently.</p><p>Let’s begin by understanding the reasons for choosing Quasar over vanilla Vue.js when it comes to creating Progressive Web Applications (PWAs).<br> Quasar provides a number of features that make it easier and faster to develop PWAs, including:</p><ul><li><strong>Scaffolding</strong>: Quasar comes with a CLI that can be used to generate a basic PWA project structure, including the necessary configuration files. This eliminates the need to manually set up the project, saving developers time and effort.</li><li><strong>UI components:</strong> Quasar provides a large library of pre-built UI components that can be used to build PWAs. These components are designed to be mobile-friendly and easy to use, which can further reduce development time.</li><li><strong>Code generation:</strong> Quasar also comes with a code generation tool that can be used to generate code for common PWA functionalities, such as routing, services, and directives. This can further reduce the amount of code that developers need to write manually.</li><li><strong>Plugin integration:</strong> Quasar seamlessly integrates with popular Vue plugins and libraries, such as Vue Router, Vuex, and Axios. This allows developers to use these popular tools without having to worry about compatibility issues.</li></ul><p>For all these reasons, Quasar PWA configuration is much better than the normal PWA with Vue.js in terms of development.</p><h3>Quasar PWA tutorial for Blogify</h3><p>In Blogify, we’re set to integrate the standout features of PWAs using Quasar, covering:</p><p>🏠 Home Screen Installation<br>🔄 Precaching<br>📊 Caching Strategies<br>🔄 Background Sync<br>🔔 Push Notifications</p><p>You will learn how to make Blogify, a Medium-like platform, into a Progressive Web App using Quasar. This will allow you to create a website and app with exciting features like those of native mobile apps.</p><p>But wait, before we start building our “Blogify” masterpiece, let’s take a quick demo tour to see what’s in store.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FbKHrM3ipu9M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbKHrM3ipu9M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FbKHrM3ipu9M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/42fe69bf6896d5521d26350193889ea6/href">https://medium.com/media/42fe69bf6896d5521d26350193889ea6/href</a></iframe><p><strong><em>Experience the live demonstration:</em></strong><em> </em><a href="https://quasar-blogify.netlify.app/"><em>Quasar-blogify.</em></a></p><p>If you’re all set, let’s dive into creating your “Blogify” masterpiece using Quasar v2, Firebase, Node, Express, and Vue 3! 🚀</p><h4>Prerequisites:</h4><p>Ensure Node is &gt;=14 (or a newer LTS version) and NPM is &gt;=6.14.12 or Yarn is &gt;=1.21.1 installed on your machine.</p><p><strong>Setting Up Your Project:</strong></p><p>Let’s install Quasar using CLI and create a new Quasar Project:</p><pre>npm i -g @quasar/cli<br>npm init quasar</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWJ1XWDQaf9NGxX-_dPAqg.png" /></figure><p>Once the project is created, execute the following commands:</p><pre>cd quasar-blogify<br> quasar dev # or: yarn quasar dev # or: npx quasar dev</pre><p>It will run the project, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MlRs6k3naLQJ3zia0opWA.png" /></figure><p>You can see the folder structure of the Quasar project below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*K_PHyIxEub1wzb80Ktu5zA.png" /></figure><p>You can save development time by exploring my GitHub repository for PWA development. It’s packed with ready-to-use code for CRUD operations and essential Quasar features. Use it as your guide to speed up your progress.</p><p>GitHub Repository: <a href="https://github.com/divyasonaraa/quasar-blogify">Blogify</a></p><p>Create Layout, add pages, and create components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*V5DWrjSCuunOZc19xPzdAg.png" /></figure><p>Once you’ve configured layout pages, components, and routing, the UI will appear as shown below (the card currently contains static data):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUVUGDTowVpn_V7zhTwxpw.png" /></figure><p>Following the establishment of the basic layout, let’s proceed to connect to the database and backend.</p><h4>Create a Firebase project</h4><ul><li>Create a new Firebase project called “Blogify” <a href="https://console.firebase.google.com/">here</a>.</li></ul><h4>Create a Cloud Firestore database</h4><ul><li>Create a Cloud Firestore database (make sure you start in test mode).</li><li>Add a collection named “blogs.”</li><li>Add some dummy blog data.</li><li>Each blog should have the fields id, title, content, liked, favorite, created_at.</li></ul><h4>Setup a Node.js and Express backend</h4><ul><li>Create a subfolder for your backend and initialize with npm in it.</li><li>Install Express and Nodemon.</li><li>Create an Express app with a simple GET endpoint that returns a string.</li><li>Launch the app and make sure the endpoint works in the browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*Id7Gfqq0gaJQOiPyHvZ7CA.png" /></figure><h4>Get the app running</h4><ul><li>Create a new project using the Firebase Console named Blogify (disable Google Analytics).</li><li>On the Project Overview page, click on the Web icon below <strong>Get started by adding Firebase to your app.</strong></li><li>Name the app Blogify and click <strong>Register app.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*0zGPiXCmDBCwtzZakYyrIA.png" /></figure><ul><li>Click <strong>Continue to console.</strong></li><li>Click on <strong>1 app</strong> &gt; <strong>Settings icon</strong> &gt; <strong>Service accounts.</strong></li><li>You may need to click <strong>Create Service account.</strong></li><li>Copy the databaseURL from the code sample and paste it into backend/index.js in your project.</li><li>Save index.js .</li><li>On Firebase Console — Click <strong>Generate new private key</strong> &gt; <strong>Generate key.</strong></li><li>Save the JSON file to your backend folder and rename it to serviceAccountKey.json .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*_sPahSxIvSBiRPjvLfuIbA.png" /></figure><ul><li>On Firebase Console — Click <strong>Database</strong> &gt; <strong>Create database</strong> &gt; <strong>Start in test mode</strong> &gt; <strong>Choose a location</strong> &gt; Click <strong>Done.</strong></li></ul><p>The provided code in <a href="https://gist.github.com/divyasonaraa/49af2847d55f8cab7dce81ead83a52d2"><strong><em>index.js</em></strong></a><em> </em>initializes the Firebase Database and includes all the endpoints for our Blogify app.</p><ul><li>Install dependencies for both the app and server:</li></ul><pre>npm install</pre><pre>cd backend<br>npm install</pre><ul><li>Launch the backend server:</li></ul><pre>cd backend<br>npm start</pre><ul><li>Launch the app in PWA mode and ensure it’s working:</li></ul><pre>quasar dev -m pwa</pre><p>Executing this command generates a src-pwa folder. We’ll explore it shortly and update custom-service-worker.js for our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*x3PJ9vwjeX1UQ2pBTIxZuw.png" /></figure><p>Our app is now running in PWA mode. A noticeable change is the installation icon in the address bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Py_AnkLaarRIYPYpfvOfHQ.png" /><figcaption>PWA mode</figcaption></figure><p>Every PWA requires a manifest file, a JSON file that informs the browser about how the app should be displayed. It includes details like titles, descriptions, colors, icons, and whether the app should be on full screen or retain some browser elements.</p><p>For a PWA without Quasar, we’d manually create the manifest JSON file and link it to our homepage using a tag like this.</p><pre>&lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot; &gt;</pre><p>Quasar automatically generates and links the manifest.json file, eliminating the need for the above tag. View the manifest.json by opening <a href="http://localhost:9200/manifest.json">http://localhost:9200/manifest.json</a> while running your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*ojmqH81vulpK14tftnS2hw.png" /></figure><p>The manifest.json file includes details like name, orientation, and background color. Customize it for changes such as updating your app’s name.</p><h3>1. Home screen installation 🏠</h3><p>We’ll enhance our app by integrating a visually appealing banner for home screen installation. This banner will only appear on supported devices when the app is ready to install and users can choose to hide it if they find it annoying.</p><p>Update your MainLayout.vuewith this piece of code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0130e4fb5e8aa125ba7f7ee5f37cf21/href">https://medium.com/media/b0130e4fb5e8aa125ba7f7ee5f37cf21/href</a></iframe><p><strong><em>Installation Banner Setup:</em></strong></p><ul><li><em>showInstallBanner c</em>ontrols the display of the installation banner.</li><li><em>deferredPrompt s</em>tores the installation prompt triggered by user interaction.</li></ul><p><strong><em>Banner Rendering:</em></strong></p><ul><li>Renders the installation banner within the <strong>&lt;q-footer&gt;</strong> component.</li><li>Provides options for the user to install the app (Yes), install later (Later), or never install it (Never).</li></ul><p><strong><em>Installation Handling:</em></strong></p><ul><li>Calls the <strong><em>installApp()</em> </strong>when the user clicks “Yes” in the banner.</li><li>Hides the banner, prompts the user to install the app using <strong><em>deferredPrompt.prompt(),</em></strong><em> </em>and waits for the user’s choice.</li><li>If the user accepts the installation, call <strong><em>neverShowInstallAppBanner</em></strong> to set a flag indicating the user chose to install the app.</li></ul><p><strong><em>Never Show Banner Again:</em></strong></p><ul><li>If the user clicks “Later” or “Never,” sets <strong><em>showInstallBanner</em></strong> to false.</li><li>Stores a flag (`<em>neverShowInstallBanner</em>`) in local storage to ensure the installation banner is not shown again.</li></ul><h4>Time to execute:</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVkIX_0_WexU&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVkIX_0_WexU&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FVkIX_0_WexU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9011997d8a537baf742f03cf8d813dc/href">https://medium.com/media/e9011997d8a537baf742f03cf8d813dc/href</a></iframe><h3>2. Precaching 🔄</h3><p>Precaching enables storing core HTML, Javascript, images, etc., in the user’s browser cache on the initial app run. This optimizes performance by loading resources from the cache rather than the network on subsequent visits and allows offline app launch.</p><p>Let’s integrate precaching into our app! In Quasar v2, it’s easier with the simplified setup in custom-service-worker.js. Quasar v2 automatically includes and preloads the `precacheAndRoute` method from Workbox, optimizing asset and route caching for improved PWA performance and offline capabilities.</p><p>To enable precaching in Quasar v2, just update quasar.config.js with:</p><pre>pwa: {<br> workboxPluginMode: &#39;InjectManifest&#39;<br>}</pre><p>Ensure to deploy your app on a platform for optimal results before proceeding.</p><h4>Seeing the code in action:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9I17NAATNvd3qXf1R2MLQ.png" /><figcaption>Precaching</figcaption></figure><h3>3. Caching strategies 📊</h3><p>We’ll manage caching for our local requests, but what about external ones? Like images, fonts, or API calls from outside sources?</p><p>Let’s check out a few caching strategies and then implement them in our app.</p><h4><a href="https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-first-falling-back-to-network">Cache first, falling back to network</a></h4><p>Utilize a <em>cache first strategy</em> for optimizing speed and enabling offline functionality, especially for requests like Google font files, which don’t change frequently. This approach ensures loading from the cache whenever possible, with a fallback to the network if the file is not in the cache.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*b-WHF0rfe0GJl9kP" /><figcaption>Image Credit: <a href="https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/service-workers">Microsoft Docs</a></figcaption></figure><h4><a href="https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache">Network first, falling back to cache</a></h4><p>We use a <em>network first</em> strategy for our app&#39;s API requests to ensure we always fetch the latest information. The app prioritizes retrieving data from the network and falls back to the cache only if the network is unavailable or there&#39;s an API issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*EPGHHcUsYjVPSLMF" /><figcaption>Image Credit: <a href="https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/service-workers">Microsoft Docs</a></figcaption></figure><h4><a href="https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale-while-revalidate">Stale-while-revalidate</a></h4><p>Utilizing a strategy, our page leverages the service worker to retrieve cached requests for the browser. Simultaneously, the service worker checks the network for the same request, updating the cache with the latest data if available. This strategy is effective for non-critical requests where the latest data isn’t always necessary. We’ll implement this approach for all HTTP requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*CE6M_7z_OtR7Az0F" /><figcaption>Image Credit: <a href="https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/service-workers">Microsoft Docs</a></figcaption></figure><p>Let’s implement these strategies in our app by updating your custom service worker with the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aeff821279bc6f081ebd4b804112572/href">https://medium.com/media/7aeff821279bc6f081ebd4b804112572/href</a></iframe><h4>Putting it to the test:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kfk06kLG2L_q-mN6d41AoQ.png" /><figcaption>Cache first, falling back to the network</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0Bh0dS6UROMs2DI8Jzp_g.png" /><figcaption>Network first, falling back to the cache</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dlFGNkZiE__jB25JjUEmA.png" /><figcaption>Stale-while-revalidate</figcaption></figure><blockquote>You may need to Clear Site Data, Close &amp; Reload Chrome to see the output.</blockquote><p>We have more caching strategies; to know about all of them, check these <a href="https://developer.chrome.com/docs/workbox/caching-strategies-overview/">workbox strategies.</a></p><h3>4. Background sync 🔄</h3><p>Precaching and caching enhance app performance and enable offline launch, while background sync ensures full offline functionality. It keeps the app state synchronized even when the user is offline. Watch the video below for a demonstration of offline functionality.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXZWii1Hdlew&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXZWii1Hdlew&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FXZWii1Hdlew%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b01c90b6fe5c3f86e42980666ade9ca/href">https://medium.com/media/2b01c90b6fe5c3f86e42980666ade9ca/href</a></iframe><p>Let’s implement this feature in our app.</p><ul><li>Set up a background sync queue for requests to our Create Blog endpoint. Update custom-service-worker.js<em>.</em></li></ul><blockquote><strong>Note:</strong> You can detect for background sync support first if you like, by checking if &#39;sync&#39; is in the self.registration object.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c14138539c7e0e3f5fe1fac63b43dc82/href">https://medium.com/media/c14138539c7e0e3f5fe1fac63b43dc82/href</a></iframe><p>Redirect to the home page if the blog is created offline. For that, we need to check for offline status in createBlog() in Create.vue:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21524f14af7fbd2c5a0ac11ab158184b/href">https://medium.com/media/21524f14af7fbd2c5a0ac11ab158184b/href</a></iframe><p>Now, it will be great if we grab the offline blogs that are stored in this queue in the indexedDB database.</p><p>To achieve this, we’ll utilize the <a href="https://github.com/jakearchibald/idb">idb Library</a>. Install the library by executing the following command:</p><pre>npm install idb --save</pre><p>Enhance the code to display offline blogs in a list with an offline style:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66ac3bf2cb8a1e75d7e7507da8e919b4/href">https://medium.com/media/66ac3bf2cb8a1e75d7e7507da8e919b4/href</a></iframe><h4>Let’s see it in action:</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQl34t844AsY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQl34t844AsY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQl34t844AsY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e79dbf269b91b6fb875c1fc0989993ac/href">https://medium.com/media/e79dbf269b91b6fb875c1fc0989993ac/href</a></iframe><h3>5. Push notifications 🔔</h3><p>To enable push notifications, there are several steps involved:</p><ol><li><strong>User Permission</strong><br> Ask users for permission to send push notifications via their browser.<br> Once granted, the browser is allowed to display native notifications on the user’s device.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*209HrPnmqB1f92JEKXDvXg.png" /></figure><p>Update the IndexPage.vueto see the above banner.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7da8b314fe63161608398c2a4ec7585/href">https://medium.com/media/f7da8b314fe63161608398c2a4ec7585/href</a></iframe><p><strong>2. Backend Setup</strong></p><ul><li>Implement a backend system to manage push subscriptions and send push messages to the associated push servers.</li></ul><p>Use the <a href="https://www.npmjs.com/package/web-push">web-push</a> library for subscriptions and notifications. Install it in the backend folder with this command:</p><pre>npm install web-push --save</pre><p>Generate keys by following the command:</p><pre>web-push generate-vapid-keys</pre><p>Update index.jswith the provided code for backend push notifications:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e99f62f480ad87ad1b141a91a1652ab4/href">https://medium.com/media/e99f62f480ad87ad1b141a91a1652ab4/href</a></iframe><p><strong>3. Push Subscription</strong></p><ul><li>Create a push subscription for each user, associating their browser with the relevant push notification server (e.g., Chrome or Firefox).</li><li>Store subscription details, including unique keys and push server information, in a backend database.</li></ul><p>Now with the new <em>/createSubscription</em> endpoint, let’s generate a subscription when the user grants notification permission. Update the script in IndexPage.vuewith the provided code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe663639f57781cfe8e7ce358348af0c/href">https://medium.com/media/fe663639f57781cfe8e7ce358348af0c/href</a></iframe><p><strong>4. Service Worker</strong></p><ul><li>Use a service worker to listen for push events in the background, even if the app is closed.</li><li>When a push event is received, display the notification to the user.</li></ul><p>Add this code to custom-service-worker.js to track Push events and respond to user clicks on notifications.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb599865055f328042f6297c2337d17f/href">https://medium.com/media/fb599865055f328042f6297c2337d17f/href</a></iframe><blockquote><strong>Protect Subscriptions:</strong><br>Secure push subscriptions with unique keys to ensure that only the authorized backend server can send messages to the user’s browser.</blockquote><p>Fantastic! We’ve successfully set up push notifications and covered the way for exciting interactions with our users.</p><p>Now, let’s witness the magic in action! 📱💬</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FkRdBgOT2YXE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkRdBgOT2YXE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FkRdBgOT2YXE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e62f9408403fd20e6be20ae4c6b0deaf/href">https://medium.com/media/e62f9408403fd20e6be20ae4c6b0deaf/href</a></iframe><h4>Wrapping up</h4><p>As we finish up, remember that PWAs are cool because they can go beyond regular apps. With Quasar, you didn’t just make an app but created something flexible that works well on any device.</p><p>Keep having fun with your coding adventures, and may your PWAs stand out online!</p><p>Visit <a href="https://divyasonara7.github.io/introduction-to-quasar/">this link</a> to learn about Quasar’s magic and how it can enhance your development experience.</p><blockquote><strong>For more updates on the latest development trends, follow the </strong><a href="https://medium.com/simform-engineering"><strong>Simform Engineering</strong></a><strong> blog.</strong></blockquote><blockquote><strong>Follow Us: </strong><a href="https://twitter.com/simform"><strong>Twitter</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/simform/"><strong>LinkedIn</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74b09723a91d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/building-the-future-with-quasar-a-vue-js-framework-revolution-74b09723a91d">Building the Future with Quasar: A Vue.js Framework Revolution</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>