Reader small image

You're reading from  Vue.js 3 Design Patterns and Best Practices

Product typeBook
Published inMay 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803238074
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Pablo David Garaguso
Pablo David Garaguso
author image
Pablo David Garaguso

Pablo David Garaguso was born in Argentina, and graduated from computer sciences in CAECE University Mar del Plata, and also an MBA in CEMA University in Buenos Aires. He worked as Computer Consultant and Manager in multiple positions in South America and Europe for almost 20 years. He currently works as a Solutions Architect and full-stack engineer for FamilySearch Int. in Finland. His systems and applications are used in Latin America, Europe, Africa, and other parts of the world.
Read more about Pablo David Garaguso

Right arrow

In-source testing

With in-source testing, we can indicate to Vitest to look into our JavaScript and Single Component Files for the tests to run, as opposed to specific files. These alternatives are not exclusive to each other, so we could have both active at the same time. The reason behind this is that, in some cases, a test case would benefit to be “close” to the original code that it is trying to assert. Such code must be placed at the end of our file following this format:

if (import.meta.vitest) {
    const { describe, test, expect } = import.meta.vitest
   //... Test functions here
}

Then, for Vitest to find this code in our files, we also need to modify the vite.config.js file to include the following:

export default defineConfig({
    test: {
        includeSource: ['src/**/*.{js,ts}'],
        // other configurations...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Vue.js 3 Design Patterns and Best Practices
Published in: May 2023Publisher: PacktISBN-13: 9781803238074

Author (1)

author image
Pablo David Garaguso

Pablo David Garaguso was born in Argentina, and graduated from computer sciences in CAECE University Mar del Plata, and also an MBA in CEMA University in Buenos Aires. He worked as Computer Consultant and Manager in multiple positions in South America and Europe for almost 20 years. He currently works as a Solutions Architect and full-stack engineer for FamilySearch Int. in Finland. His systems and applications are used in Latin America, Europe, Africa, and other parts of the world.
Read more about Pablo David Garaguso