Skip to content

Commit

Permalink
chore(vitest): migrate from jest to vitest
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <[email protected]>
  • Loading branch information
raimund-schluessler committed Dec 30, 2023
1 parent 5f6f5b5 commit 58a3309
Show file tree
Hide file tree
Showing 21 changed files with 2,739 additions and 1,374 deletions.
3,446 changes: 2,203 additions & 1,243 deletions package-lock.json

Large diffs are not rendered by default.

60 changes: 5 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"lint:fix": "eslint --ext .js,.vue src tests --fix",
"stylelint": "stylelint 'css/**/*.scss'",
"stylelint:fix": "stylelint 'css/**/*.scss' --fix",
"test": "jest --verbose"
"test": "vitest run"
},
"repository": {
"type": "git",
"url": "[email protected]:nextcloud/tasks.git"
},
"type": "module",
"type": "module",
"bugs": "https://github.com/nextcloud/tasks/issues",
"contributors": [],
"dependencies": {
Expand Down Expand Up @@ -66,66 +66,16 @@
"@nextcloud/stylelint-config": "^2.3.1",
"@nextcloud/vite-config": "^1.2.0",
"@vue/test-utils": "^1.3.6",
"@vue/vue2-jest": "^29.2.6",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-serializer-vue": "^3.1.0",
"jest-transform-stub": "^2.0.0",
"happy-dom": "^12.10.3",
"mockdate": "^3.0.5",
"regenerator-runtime": "^0.14.1"
"regenerator-runtime": "^0.14.1",
"vitest": "^1.1.0"
},
"engines": {
"node": "^20.0.0",
"npm": "^9.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"vue"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1",
"^Assets/(.*)$": "<rootDir>/src/assets/$1",
"^Components/(.*)$": "<rootDir>/src/components/$1",
"^Directives/(.*)$": "<rootDir>/src/directives/$1",
"^Fonts/(.*)$": "<rootDir>/src/fonts/$1",
"^Mixins/(.*)$": "<rootDir>/src/mixins/$1",
"^Models/(.*)$": "<rootDir>/src/models/$1",
"^Store/(.*)$": "<rootDir>/src/store/$1",
"^Utils/(.*)$": "<rootDir>/src/utils/$1",
"^Views/(.*)$": "<rootDir>/src/views/$1"
},
"testEnvironment": "jsdom",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
"^.+\\.vue$": "<rootDir>/node_modules/@vue/vue2-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
},
"transformIgnorePatterns": [
"/node_modules/(?!(.*vue-material-design-icons)|(uuid)|(.*vue-select)|(@nextcloud/vue)|(.*p-*))"
],
"snapshotSerializers": [
"<rootDir>/node_modules/jest-serializer-vue"
],
"setupFilesAfterEnv": [
"./tests/javascript/unit/setup.js"
],
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/**/*.{js,vue}",
"!**/node_modules/**"
],
"coverageReporters": [
"json",
"text",
"html",
"lcov",
"clover"
]
},
"browserslist": [
"extends @nextcloud/browserslist-config"
]
Expand Down
24 changes: 14 additions & 10 deletions src/components/TaskDragContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ import { sort } from '../store/storeHelper.js'
import draggable from 'vuedraggable'
import { mapGetters, mapActions, mapMutations } from 'vuex'

import { defineAsyncComponent } from 'vue'

/**
* We asynchronously import here, because we have a circular dependency
* between TaskDragContainer and TaskBody which otherwise cannot be resolved.
* See https://vuejs.org/guide/components/async.html#basic-usage
*
* @return {object} The TaskBody component
*/
const TaskBody = defineAsyncComponent(() =>
import('./TaskBody.vue'),
)

export default {
name: 'TaskDragContainer',
components: {
/**
* We asynchronously import here, because we have a circular dependency
* between TaskDragContainer and TaskBody which otherwise cannot be resolved.
* See https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components
*
* We load it "eager", because the TaskBody will always be required.
*
* @return {object} The TaskBody component
*/
TaskBody: () => import(/* webpackMode: "eager" */ './TaskBody.vue'),
TaskBody,
draggable,
},
props: {
Expand Down
1 change: 0 additions & 1 deletion src/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Vue.use(Vuex)

Vue.prototype.$OC = OC
Vue.prototype.$OCA = OCA
Vue.prototype.$appVersion = appVersion

document.addEventListener('DOMContentLoaded', () => {
OCA.Dashboard.register('tasks', (el) => {
Expand Down
1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ if (!OCA.Tasks) {

Vue.prototype.$OC = OC
Vue.prototype.$OCA = OCA
Vue.prototype.$appVersion = appVersion

OCA.Tasks.App = new Vue({
el: '.app-tasks',
Expand Down
2 changes: 1 addition & 1 deletion src/store/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ const actions = {
if (taskData.calendar.readOnly) {
return
}
const task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Tasks v' + this._vm.$appVersion + '\nEND:VCALENDAR', taskData.calendar)
const task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Tasks v' + appVersion + '\nEND:VCALENDAR', taskData.calendar)

task.created = ICAL.Time.now()
task.summary = taskData.summary
Expand Down
1 change: 0 additions & 1 deletion src/talk.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import Vue from 'vue'

Vue.prototype.$OC = OC
Vue.prototype.$OCA = OCA
Vue.prototype.$appVersion = appVersion

window.addEventListener('DOMContentLoaded', () => {
if (!window.OCA?.Talk?.registerMessageAction) {
Expand Down
Loading

0 comments on commit 58a3309

Please sign in to comment.