Skip to content

Commit

Permalink
Merge pull request #4 from huntdatacenter/vitest
Browse files Browse the repository at this point in the history
add vitest
  • Loading branch information
matuskosut authored Feb 20, 2024
2 parents 86a55db + d0f7cf0 commit 0e4a9ad
Show file tree
Hide file tree
Showing 6 changed files with 1,299 additions and 14 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
"scripts": {
"dev": "vitepress dev pages",
"build": "vitepress build pages",
"preview": "vitepress preview pages"
"preview": "vitepress preview pages",
"test": "vitest"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/test-utils": "^2.4.4",
"happy-dom": "^13.3.8",
"vite-plugin-vuetify": "^2.0.1",
"vitepress": "^1.0.0-rc.41",
"vitest": "^1.3.0",
"vue": "^3.4.15",
"vuetify": "^3.5.4"
},
Expand Down
13 changes: 13 additions & 0 deletions tests/ProductSlider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mount } from "@vue/test-utils";
import ProductSlider from "../pages/.vitepress/components/ProductSlider.vue";
import { expect, test, it, describe } from "vitest";

describe('ProductSlider', () => {
it('renders the component', () => {
const wrapper = mount(ProductSlider, {
products: [],
});
expect(wrapper.exists()).toBe(true);
});
// Add more test cases as needed
});
7 changes: 7 additions & 0 deletions tests/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// sum.test.ts
import { expect, test } from 'vitest'
import { sum } from './example'

test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3)
})
4 changes: 4 additions & 0 deletions tests/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// sum.ts
export function sum(a: number, b: number): number {
return a + b
}
10 changes: 10 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "vitest/config";
import vue from "@vitejs/plugin-vue"; // Import the plugin here

export default defineConfig({
test: {
environment: "happy-dom",
globals: true,
},
plugins: [vue()], // Include it in your array of plugins here
});
Loading

0 comments on commit 0e4a9ad

Please sign in to comment.