Home

Awesome

Vue3 starter kit

Arguably the most important parts of an app (authentication and handling payment methods) are also the most repetitive and boring to implement. This starter kit aims to solve that problem by providing a solid foundation for your next Vue3 app.

Screenshot

Demo

https://vue3-starter-demo.netlify.app (Note: this is a pure client-side demo so there is no backend - you won't be able to login or test payment methods)

See the components below for a more detailed preview.

Preview components in Storybook

https://vue3-starter-storybook.netlify.app/index.html

Comes with

Features

Pages and routing

Forms

Forms are split into separate components so they can be used either on pages (like a login page) or in modals (like a login to continue modal).

The following forms are included:

Components

BaseForm

A helper component that makes it easy to create forms with validation. It's a wrapper around native browser validation.

Props:

Methods that can be called (make sure to set a ref on the BaseForm):

Slots:

BaseButton

Automatically render a button, a with a role of button, or router-link depending on the props passed (if href its an a, if to its a router-link, otherwise its a button)

Props:

Slots:

BaseModal

Render a modal with an optional backdrop and close button.

Props:

Slots:

Continuous Integration and Continuous Deployment

Project Setup

This starter kit is actively tested with and recommends using Node 20.

npm install

Make sure to copy the .env.example to .env.local and fill in the values.

After installing everything - you should run the E2E tests to make sure everything is working properly. See the E2E tests section for more information.

Your first changes

This starter kit is designed to provide a strong test foundation. When you'll change something in the code that will modify the element itself (changing the text for example), your snapshot and visual tests will fail. You can easily update snapshots with the commands provided in the starter kit (read below). This kind of workflow is very useful because it ensures that changes are intentional and that you are aware of them.

Other significant changes to make

Compile and Hot-Reload for Development

npm run dev

Wether you are using the Docker environment or not, you should now be able to access the app at http://localhost:8001.

Type-Check, Compile and Minify for Production

npm run build

Run Unit Tests with Vitest

npm run test:unit

Run End-to-End Tests with Cypress

npm run test:e2e:dev

This runs the end-to-end tests against the Vite development server. It is much faster than the production build.

But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):

npm run build
npm run test:e2e

Note that there seems to be an issue when trying to run this command in a pre-commit/push hook - see similar issue here: https://stackoverflow.com/questions/73108965/module-not-found-error-when-adding-cypress-command-to-husky-pre-push

Lint with ESLint

npm run lint

Translation keys validation

npm run translation-key-check

Note, if you expand the supported languages, make sure to update the .vue-translation.js file to include the new language.

Storybook Components

npm run storybook

This will start the Storybook server and open a new tab in your browser.

You can read more about Storybook here.

Run Visual Tests with Storybook

npm run test:visual:ci

If you already have torybook running, you can run the visual tests with:

npm run test:visual

When something changes (intentionally) in the components visually, you can regenrate the baseline images with:

npm run test:visual:update

Backend setup

This starter kit was designed to work with a Laravel based backend, but any backend that implements the required functionality would work.

Assumptions made by this starter kit:

Contributing

Test driven approach

We use a test driven approach for this starter kit.

You should almost never modify existing tests. Any modified tests will require merge approval.

If you find a bug, first write a test that will fail because of the bug. Then fix the bug and make sure the test passes.

If you want to add a new feature, write a test that will fail because of the missing feature. Then add the feature and make sure the test passes. New tests do not require approval.

<!-- Show image https://res.cloudinary.com/practicaldev/image/fetch/s--2bUj5oX1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26tdj40bmlnmw09fb27h.png -->

Using the right tests for the job

In visual testing, you generally go from the smallest component (e.g. testing a button) to the largest, while in E2E tests you go from the largest (e.g. testing a whole page) to the smallest. Unit tests test your logic in between.

  1. For functionality, use unit tests (e.g. if I give this value to this function, will it return the correct result?)
  2. For user interactions, use end-to-end tests (e.g. if I click this button, will it show the correct modal?)
  3. For visual changes, use visual tests with Storybook (e.g. if I change this CSS, will I still see the element in the correct place? Will it still be centered?)

Be careful not to over-test. If you find yourself testing the same thing in multiple places, you should ask yourself if you are testing the right things in the right places. Over-tested code can be hard to update and grow.

Test questions - example of a card
Test questions - example of a modal