Skip to content

Commit

Permalink
✨ Add Jest for unit tests (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Broussard <deraw@outlook.fr>
  • Loading branch information
DavidFyon and deraw authored Sep 12, 2023
1 parent 88c6dd7 commit 5dfc465
Show file tree
Hide file tree
Showing 6 changed files with 3,629 additions and 1,065 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ logs
.env
.env.*
!.env.example

# Tests coverage
**/tests/**/coverage/
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/env']
};
51 changes: 51 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
testEnvironment: 'jsdom',
testEnvironmentOptions: {
customExportConditions: ['node', 'node-addons']
},
testMatch: [
'<rootDir>/**/tests/*.spec.ts',
'<rootDir>/tests/unit/**/*.spec.ts'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1'
},
transform: {
'^.+\\.(js)$': 'babel-jest',
'^.+\\.(ts)$': 'ts-jest',
'^.+\\.(css|scss|png|jpg|svg)$': 'jest-transform-stub',
'^.+\\.(vue)$': '@vue/vue3-jest'
},
coverageReporters: [
'text',
'html',
'lcov',
'text-summary'
],
coverageDirectory: '<rootDir>/tests/unit/coverage',
collectCoverage: true,
collectCoverageFrom: [
'**/*.{ts,vue}',
'!**/node_modules/**',
'!**/*.d.ts',
'!**/*.config.ts',
'!**/decorators.ts',
'!**/constants/**',
'!**/router/**',
'!**/main.ts',
'!**/theme/**',
'!**/plugins/**',
'!**/i18n.ts',
'!**/store/**',
'!**/services/**',
'!**/tests/**',
'!**/translations/**'
],
globals: {
API_URL: 'http://localhost:8080'
}
};

export default config;
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
"postinstall": "nuxt prepare",
"test:unit": "jest"
},
"devDependencies": {
"@babel/preset-env": "7.22.15",
"@invictus.codes/nuxt-vuetify": "0.3.0",
"@nuxt/devtools": "0.8.2",
"@nuxtjs/i18n": "8.0.0-rc.4",
"@types/jest": "29.5.4",
"@types/node": "18.17.0",
"@vue/test-utils": "2.4.1",
"@vue/vue3-jest": "29.2.6",
"axios": "1.5.0",
"dayjs-nuxt": "1.1.2",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-transform-stub": "2.0.0",
"nuxt": "3.7.0",
"sass": "1.66.1",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"vue-facing-decorator": "3.0.2",
"vue-input-facade": "3.0.0-beta.3",
"vuex": "4.1.0",
Expand Down
Loading

0 comments on commit 5dfc465

Please sign in to comment.