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

chore(vitest): migrate from jest to vitest #2409

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -295,7 +295,7 @@
appendTasks(state, tasks = []) {
state.tasks = tasks.reduce(function(list, task) {
if (task instanceof Task) {
Vue.set(list, task.key, task)

Check warning on line 298 in src/store/tasks.js

View workflow job for this annotation

GitHub Actions / NPM lint

Caution: `Vue` also has a named export `set`. Check if you meant to write `import {set} from 'vue'` instead
} else {
console.error('Wrong task object', task)
}
Expand Down Expand Up @@ -701,7 +701,7 @@
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
13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo1.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo2.ics

This file was deleted.

11 changes: 0 additions & 11 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo3.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo3_1.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo3_1_1.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo3_2.ics

This file was deleted.

12 changes: 0 additions & 12 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo4.ics

This file was deleted.

16 changes: 0 additions & 16 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo4_1.ics

This file was deleted.

16 changes: 0 additions & 16 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo5.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo6.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar1/vcalendar-vtodo7.ics

This file was deleted.

12 changes: 0 additions & 12 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo1.ics

This file was deleted.

12 changes: 0 additions & 12 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo2.ics

This file was deleted.

12 changes: 0 additions & 12 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo3.ics

This file was deleted.

12 changes: 0 additions & 12 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo4.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo4_1.ics

This file was deleted.

13 changes: 0 additions & 13 deletions tests/assets/ics/vcalendars/calendar2/vcalendar-vtodo4_2.ics

This file was deleted.

Loading
Loading