Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Jest for unit tests #8

Merged
merged 5 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div class="hello">
<h1>{{ greeting }}</h1>
</div>
</template>

<script setup>
import { defineProps } from "vue";

const props = defineProps({
greeting: {
type: String,
default: "Hello, world!",
},
});
</script>
27 changes: 27 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
preset: 'ts-jest',
moduleFileExtensions: [
'js',
'json',
'vue',
'ts',
'tsx',
],
transform: {
// process `*.vue` files with `vue-jest`
'^.+\\.vue$': 'vue-jest',
// process TypeScript with `ts-jest`
'\\.(ts|tsx)$': 'ts-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
'jest-transform-stub',
},
testMatch: [
'<rootDir>/src/**/tests/*.spec.ts',
deraw marked this conversation as resolved.
Show resolved Hide resolved
],
setupFiles: [
'<rootDir>/tests/setup-jest.ts',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
};
4 changes: 2 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default defineNuxtConfig({
ssr: false,
modules: [
'@invictus.codes/nuxt-vuetify',
'dayjs-nuxt'
'dayjs-nuxt',
'@nuxtjs/i18n',
],

vuetify: {
Expand Down Expand Up @@ -44,7 +45,6 @@ export default defineNuxtConfig({
plugins: [
'~/plugins/axios.ts',
'~/plugins/vuex.ts',
'@nuxtjs/i18n',
{ src: '~/plugins/vuex-persist', ssr: false },
],
});
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
"postinstall": "nuxt prepare",
"test": "jest run"
},
"devDependencies": {
"@invictus.codes/nuxt-vuetify": "^0.2.23",
"@nuxt/devtools": "latest",
"@nuxtjs/i18n": "8.0.0-rc.3",
"@nuxt/test-utils": "^3.6.5",
"@types/jest": "^29.5.3",
"@types/node": "^18.17.0",
"@vue/test-utils": "^2.4.1",
"babel-jest": "^29.6.2",
"@nuxtjs/i18n": "8.0.0-rc.3",
"axios": "^1.4.0",
"dayjs-nuxt": "^1.1.2",
"jest": "^29.6.2",
"jest-transform-stub": "^2.0.0",
"nuxt": "^3.6.5",
"sass": "^1.63.6",
"ts-jest": "^29.1.1",
"vue-jest": "^3.0.7",
"vue-facing-decorator": "^3.0.2",
"vuex": "^4.1.0",
"vuex-persist": "^3.1.3"
Expand Down
Loading