DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Core Badge
Avatar

Anthony Gore

DZone Core CORE

Founder at Vue.js Developers

Chiang Mai, TH

Joined May 2017

https://vuejsdevelopers.com

About

I'm Anthony Gore and I'm here to teach you Vue.js! Through my books, online courses, and social media, my aim is to turn you into a Vue.js expert. I'm a Vue Community Partner, curator of the weekly Vue.js Developers Newsletter, and the founder of vuejsdevelopers.com, an online community for web professionals who love Vue.js. Curious about Vue? Take my free 30-minute "Vue.js Crash Course" to learn what Vue is, what kind of apps you can build with it, how it compares to React & Angular, and more. Enroll for free! https://courses.vuejsdevelopers.com/p/vue-js-crash-course?utm_source=dzone&utm_medium=bio

Stats

Reputation: 3591
Pageviews: 1.2M
Articles: 27
Comments: 2

Expertise

JavaScript Expertise Icon

JavaScript

  • Articles
  • Trend Reports
  • Comments

Articles

article thumbnail
Choosing Between REST and GraphQL
In this article, dive deep into the strengths and weaknesses of both REST and GraphQL so you can decide which API architecture is best for your next project.
April 25, 2022
· 5,910 Views · 7 Likes
article thumbnail
Extending Vue.js Components
Using HTML, and a little bit of Pug, this web dev expert shows us how to extend the components of our Vue.js applications.
Updated February 10, 2020
· 36,633 Views · 5 Likes
article thumbnail
Drop jQuery From Your Bootstrap Project (and Replace it With Vue.js!)
Tired of the baggage that comes along with using jQuery in your development projects, such as increased size and trick configurations? Use Vue.js instead.
Updated February 10, 2020
· 21,762 Views · 6 Likes
article thumbnail
7 Ways to Define a Component Template in Vue.js
Having a hard time deciding on which method to use to define your component template? Read on for some great tips from a Vue.js expert.
Updated February 10, 2020
· 30,340 Views · 3 Likes
article thumbnail
Don't Forget Browser Button UX In Your Vue.js App
A Vue.js whiz explains how to create different kinds of browser navigation using this powerful JavaScript framework. Read on for more!
Updated February 10, 2020
· 10,215 Views · 4 Likes
article thumbnail
Pre-Render a Vue.js App (With Node Or Laravel)
In this article, we'll explore how pre-rendering works with Vue.js and look at two examples; one with a Node.js project, one with a Laravel project.
Updated February 10, 2020
· 22,808 Views · 4 Likes
article thumbnail
4 Ways To Boost Your Vue.js App With Webpack
If you're looking to give your Vue.js-based web application a little bit of an enhancement, read on to see how Webpack can help with that.
Updated February 10, 2020
· 18,057 Views · 3 Likes
article thumbnail
3 Code Splitting Patterns For Vue.js and Webpack
In this article, a DZone MVB and Vue.js expert shows three methods you can use for architecting an app for code splitting using Vue and Webpack.
Updated February 10, 2020
· 13,229 Views · 3 Likes
article thumbnail
Build A Collapsible Tree Menu With Vue.js Recursive Components
Ever been reading a comment section of a site and wonder how they make that collapsible, indented style view? Read on to find out!
Updated February 10, 2020
· 19,556 Views · 8 Likes
article thumbnail
Managing User Permissions in a Vue.js App
Learn how to restrict user permissions using Vue.js and an open source JavaScript library so users of your can, say, post a comment but not delete a comment.
Updated February 10, 2020
· 28,299 Views · 4 Likes
article thumbnail
When to ''Unstub'' a Component in a Vue.js Unit Test
To test a component in isolation you can replace it's children components by stubbing them. Vue Test Utils can automatically do this for you with a feature called shallowMount. But what happens if a component is tightly coupled to one of its children? You can still use shallowMount, but you'll then have to selectively "unstub" the tightly coupled child. In this article, I'll show you how to use stubbing to write simpler unit tests. Note: this article was originally posted here on the Vue.js Developers blog on 2019/09/30. Testing in isolation A key idea of unit testing is to test a "unit" of the application in isolation. In component-based frontend apps, we consider the "unit" to be a component. Testing a component in isolation ensures that tests are unaffected by dependencies and other influences of children components. To isolate a component from surrounding components, you can stub it's children components. The diagram below shows how stubbing this way would affect a typical component hierarchy. Stubbing a component usually means replacing it with a simple "stand in" component with no state, logic, and a minimal template. For example, you might replace this: export default { name: "MyComponent", template: "..." props: { ... }, methods: { ... }, computed: { ... } ... }; with this: export default { name: "MyComponentStub" template: "" }; Rather than manually stubbing children components, though, Vue Test Utils offers the shallowMount feature which does it automatically. Coupled components In the real world, components aren't always completely decoupled. Sometimes a component relies on a child component and so the child can't be stubbed without losing some functionality. For example, say we make a button with a cool animation, and we want to reuse it across an app, and so we decide to create a custom component called animated-button. We now have the my-form component that uses this button component. It's been implemented such that my-form is coupled to animated-button, since the latter emits a "click" event that's used to trigger the submit method in the former. MyForm.vue Unit testing my-form Another key idea of unit testing is that we want to test the inputs and outputs of the unit and consider the internals to be a black box. In the my-form component, we should make a unit test where the input is the click of the button, while the output is the Vuex commit. We'll call this test "should commit FORM_SUBMIT when button clicked". We'll create it by first shallow mounting MyForm to isolate it from the influence of any children components as previously prescribed. MyForm.spec.js import { shallowMount } from "@vue/test-utils"; import MyForm from "@/components/MyForm"; describe("MyForm.vue", () => { it("should commit FORM_SUBMIT when button clicked", () => { const wrapper = shallowMount(MyForm); }); }); Next, we'll use the wrapper find API method to find the button component. We pass a CSS selector "animated-button" as the locator strategy. We can then chain the trigger method and pass "click" as the argument. This is how we generate the input of the test. We can then assert that a Vuex commit gets made (probably using a spy, but that's not relevant to this article so I won't detail it). MyForm.spec.js it("should commit FORM_SUBMIT when button clicked", () => { const wrapper = shallowMount(MyForm); wrapper.find("animated-button").trigger("click"); // assert that $store.commit was called }); If we try to run that, we'll get this error from Vue Test Utils: find did not return animated-button, cannot call trigger() on empty Wrapper Is the CSS selector wrong? No, the issue is that we shallow mounted the component, so all the children were stubbed. The auto-stub process changes the name of AnimatedButton to "animated-button-stub" in the template. But changing the selector from "animated-button" to "animated-button-stub" is not a solution. Auto-stubs have no internal logic, so the click event we trigger on it is not being listened to anyway. Selective unstubbing We still want to shallow mount my-form, as we want to ensure it's isolated from the influence of its children. But animated-button is an exception as it's functionality is required for the test. Vue Test Utils allows us to specify the stub for a particular component rather than using an auto-stub when shallow mounting. So the trick is to "unstub" animated-button by using its original component definition as the stub so it retains all of its functionality! To do this, let's import the AnimatedButton component at the top of the file. Now, let's go to our test and create a const stubs and assign it an object. We can put AnimatedButton as an object property shorthand. Now, we'll pass in stubs as part of our shallow mount config. We'll also replace the CSS selector with the component definition, as this is the preferred way of using the find method. MyForm.spec.js import { shallowMount } from "@vue/test-utils"; import MyForm from "@/components/MyForm"; import AnimatedButton from "@/component/AnimatedButton" describe("MyForm.vue", () => { it("should commit FORM_SUBMIT when button clicked", () => { const stubs = { AnimatedButton }; const wrapper = shallowMount(MyForm, { stubs }); wrapper.find(AnimatedButton).trigger("click"); ... }); }); Doing it this way should give you a green tick. Wrap up You always want to isolate your components in a unit test, which can easily be achieved by stubbing all the children components with shallowMount. However, if your component is tightly coupled with one of its children, you can selectively "unstub" that component by providing the component definition as a stub and overriding the auto-stub. Become a senior Vue developer in 2020. Learn and master what professionals know about building, testing, and deploying, full-stack Vue apps in our latest course. Learn more
February 7, 2020
· 5,679 Views · 2 Likes
article thumbnail
Critical CSS and Webpack: Automatically Minimize Render-Blocking CSS
Learn how to programmatically identify any CSS that's slowing down your web application, and how to minimize it to speed up load times.
Updated February 5, 2020
· 29,820 Views · 7 Likes
article thumbnail
Switching From React to Vue.js
If you're caught trying to decide between these two great JavaScript frameworks, read on to get a Vue advocate's opinion on the matter.
Updated February 4, 2020
· 28,386 Views · 17 Likes
article thumbnail
Code Splitting With Vue.js and Webpack
Learn how Vue.js and Webpack can be used to split a single page app into more optimally sized files that can be dynamically loaded.
Updated February 4, 2020
· 14,407 Views · 7 Likes
article thumbnail
Vue.js Single-File JavaScript Components in the Browser
Browser support for native JavaScript modules is finally happening. In this article, we show you what this means for Vue.js developers.
Updated February 4, 2020
· 21,940 Views · 8 Likes
article thumbnail
Avoid This Common Anti-Pattern in Full-Stack Vue/Laravel Apps
In this post, we'll look at a design pattern that makes it easy to inject initial application state into the head of the HTML page, and allows for a lot of flexibility.
Updated February 4, 2020
· 9,728 Views · 5 Likes
article thumbnail
4 AJAX Patterns for Vue.js Apps
A Vue.js expert demonstrates different AJAX patterns that can be used with Vue.js and Vuex, and gives some sample JavaScript code for each example.
Updated February 4, 2020
· 15,742 Views · 7 Likes
article thumbnail
Using JSX With Vue.js
While some people are still not sold on the use of JSX in their JavaScript, it has several benefits which we'll explore in this article.
Updated February 4, 2020
· 12,488 Views · 6 Likes
article thumbnail
Server-Side Rendering With Laravel and Vue.js 2.5
Using Laravel as the backend for your Vue.js application is a new advantage. Read on to learn how to use these two frameworks to handle SSR.
Updated February 4, 2020
· 26,539 Views · 6 Likes
article thumbnail
Use Any JavaScript Library With Vue.js
In this article, we go over the code required to add JavaScript libraries to your Vue project, as well as the ways you definitely shouldn't.
Updated February 4, 2020
· 36,330 Views · 8 Likes
article thumbnail
How to (Safely) Use a jQuery Plugin With Vue.js
While Vue developers may cringe at the thought, sometimes it's necessary to use jQuery with your Vue.js app. Learn how here!
Updated February 4, 2020
· 25,850 Views · 9 Likes
article thumbnail
7 Vue.js Backends Compared
Rails, Express, Django... the list goes on. There are so many great backed frameworks, which one should you choose? If you use Vue, read on for one expert's opinion.
Updated January 24, 2020
· 34,496 Views · 8 Likes
article thumbnail
5 Awesome Boilerplates/Templates for Vue.js Projects
A dev looks at resources for Vue developers working with SPAs, Webpack, authentication, GraphQL, documentation, and testing.
Updated January 24, 2020
· 30,752 Views · 6 Likes
article thumbnail
Create and Publish Web Components With Vue CLI 3
In this post, a Vue.js expert and web dev extraordinaire provides a tutorial on using a new wrapper library for Vue to create web components.
Updated January 17, 2020
· 26,056 Views · 8 Likes
article thumbnail
Renaming src Folder of a Vue CLI 3 Project
This can be a bit of a pain, but this Vue.js expert shows us how it's done.
Updated January 17, 2020
· 16,033 Views · 5 Likes
article thumbnail
Fallback for Blocked iframes: A (Crude) Solution With Vue.js
If your app is targeting a global user base, then you may run into issues where the iframe you've embedded doesn't render for all users.
Updated January 6, 2020
· 20,686 Views · 3 Likes
article thumbnail
Can a Vue Template Have Multiple Root Nodes (Fragments)?
It might sound a little weird at first, but if there's anyone who knows how to do it, it's this Vue developers. Read on for some expert JavaScripting!
Updated January 6, 2020
· 31,777 Views · 5 Likes

Trend Reports

Trend Report

Enterprise Application Integration

As with most 2022 trends in the development world, discussions around integration focus on the same topic: speed. What are the common integration patterns and anti-patterns, and how do they help or hurt overall operational efficiency? The theme of speed is what we aim to cover in DZone’s 2022 "Enterprise Application Integration" Trend Report. Through our expert articles, we offer varying perspectives on cloud-based integrations vs. on-premise models, how organizational culture impacts successful API adoption, the different use cases for GraphQL vs. REST, and why the 2020s should now be considered the "Events decade." The goal of this Trend Report is to provide you with diverse perspectives on integration and allow you to decide which practices are best for your organization.

Enterprise Application Integration

Trend Report

Modern Web Development

The web is evolving fast, and developers are quick to adopt new tools and technologies. DZone’s recent 2021 Modern Web Development survey served to help better understand how developers build successful web applications, with a focus on how decisions are made about where computation and storage should occur.This Trend Report will help readers examine the pros and cons of critical web development design choices, explore the latest development tools and technologies, and learn what it takes to build a modern, performant, and scalable web application. Readers will also find contributor insights written by DZone community members, who cover topics ranging from web performance optimization and testing to a comparison of JavaScript frameworks.Read on to learn more!

Modern Web Development

Trend Report

JavaScript Frameworks

JavaScript is constantly at the top of developer surveys. With the rise of Single Page Applications and front-end frameworks, and the onslaught of languages that now compile into JS, it's easy to see that JavaScript will continue to play a pivotal role in front-end and back-end development for the foreseeable future. What that future looks like exactly is in flux, especially as it relates to which frameworks are in vogue and which are on their way out. DZone’s JavaScript Frameworks Trend Report provides the perspectives of industry professionals and leaders, detailing the latest news and trends concerning JavaScript frameworks, all with the hope of giving readers a better understanding of which of these frameworks is right for their specific development needs.

JavaScript Frameworks

Comments

Using JSX With Vue.js

Jan 24, 2018 · Anthony Gore

Thank you!

4 AJAX Patterns for Vue.js Apps

Dec 07, 2017 · Anthony Gore

Hi Carolina, Uglify has an "exclude" config setting that you can use to skip this file https://webpack.js.org/plugins/uglifyjs-webpack-plugin/

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: