feat: replace jest with vitest
This commit is contained in:
parent
bc4ea82639
commit
8114012997
14 changed files with 323 additions and 1406 deletions
25
package.json
25
package.json
|
@ -12,7 +12,7 @@
|
||||||
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",
|
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",
|
||||||
"lint:markup": "vue-tsc --noEmit",
|
"lint:markup": "vue-tsc --noEmit",
|
||||||
"cypress:open": "cypress open",
|
"cypress:open": "cypress open",
|
||||||
"test:unit": "jest",
|
"test:unit": "vitest run",
|
||||||
"test:frontend": "cypress run",
|
"test:frontend": "cypress run",
|
||||||
"browserslist:update": "npx browserslist@latest --update-db"
|
"browserslist:update": "npx browserslist@latest --update-db"
|
||||||
},
|
},
|
||||||
|
@ -59,7 +59,6 @@
|
||||||
"@fortawesome/free-solid-svg-icons": "5.15.4",
|
"@fortawesome/free-solid-svg-icons": "5.15.4",
|
||||||
"@fortawesome/vue-fontawesome": "3.0.0-5",
|
"@fortawesome/vue-fontawesome": "3.0.0-5",
|
||||||
"@types/flexsearch": "0.7.2",
|
"@types/flexsearch": "0.7.2",
|
||||||
"@types/jest": "27.4.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "5.9.0",
|
"@typescript-eslint/eslint-plugin": "5.9.0",
|
||||||
"@typescript-eslint/parser": "5.9.0",
|
"@typescript-eslint/parser": "5.9.0",
|
||||||
"@vitejs/plugin-legacy": "1.6.4",
|
"@vitejs/plugin-legacy": "1.6.4",
|
||||||
|
@ -76,19 +75,19 @@
|
||||||
"eslint-plugin-vue": "8.2.0",
|
"eslint-plugin-vue": "8.2.0",
|
||||||
"express": "4.17.2",
|
"express": "4.17.2",
|
||||||
"faker": "5.5.3",
|
"faker": "5.5.3",
|
||||||
"jest": "27.4.5",
|
|
||||||
"netlify-cli": "8.6.4",
|
"netlify-cli": "8.6.4",
|
||||||
|
"happy-dom": "^2.25.1",
|
||||||
"postcss": "8.4.5",
|
"postcss": "8.4.5",
|
||||||
"postcss-preset-env": "7.2.0",
|
"postcss-preset-env": "7.2.0",
|
||||||
"rollup": "2.63.0",
|
"rollup": "2.63.0",
|
||||||
"rollup-plugin-visualizer": "5.5.2",
|
"rollup-plugin-visualizer": "5.5.2",
|
||||||
"sass": "1.45.2",
|
"sass": "1.45.2",
|
||||||
"slugify": "1.6.5",
|
"slugify": "1.6.5",
|
||||||
"ts-jest": "27.1.2",
|
|
||||||
"typescript": "4.5.4",
|
"typescript": "4.5.4",
|
||||||
"vite": "2.7.10",
|
"vite": "2.7.10",
|
||||||
"vite-plugin-pwa": "0.11.12",
|
"vite-plugin-pwa": "0.11.12",
|
||||||
"vite-svg-loader": "3.1.1",
|
"vite-svg-loader": "3.1.1",
|
||||||
|
"vitest": "^0.0.125",
|
||||||
"vue-tsc": "0.30.2",
|
"vue-tsc": "0.30.2",
|
||||||
"wait-on": "6.0.0",
|
"wait-on": "6.0.0",
|
||||||
"workbox-cli": "6.4.2"
|
"workbox-cli": "6.4.2"
|
||||||
|
@ -144,24 +143,6 @@
|
||||||
"autoprefixer": {}
|
"autoprefixer": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jest": {
|
|
||||||
"testPathIgnorePatterns": [
|
|
||||||
"cypress"
|
|
||||||
],
|
|
||||||
"testEnvironment": "jsdom",
|
|
||||||
"preset": "ts-jest",
|
|
||||||
"roots": [
|
|
||||||
"<rootDir>/src"
|
|
||||||
],
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(js|tsx?)$": "ts-jest"
|
|
||||||
},
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"ts",
|
|
||||||
"js",
|
|
||||||
"json"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"packageManager": "yarn@1.22.17"
|
"packageManager": "yarn@1.22.17"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {it, expect} from 'vitest'
|
||||||
|
|
||||||
import {calculateItemPosition} from './calculateItemPosition'
|
import {calculateItemPosition} from './calculateItemPosition'
|
||||||
|
|
||||||
it('should calculate the task position', () => {
|
it('should calculate the task position', () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {describe, it, expect} from 'vitest'
|
||||||
|
|
||||||
import {findCheckboxesInText, getChecklistStatistics} from './checklistFromText'
|
import {findCheckboxesInText, getChecklistStatistics} from './checklistFromText'
|
||||||
|
|
||||||
describe('Find checklists in text', () => {
|
describe('Find checklists in text', () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {test, expect} from 'vitest'
|
||||||
|
|
||||||
import {colorFromHex} from './colorFromHex'
|
import {colorFromHex} from './colorFromHex'
|
||||||
|
|
||||||
test('hex', () => {
|
test('hex', () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {test, expect} from 'vitest'
|
||||||
|
|
||||||
import {colorIsDark} from './colorIsDark'
|
import {colorIsDark} from './colorIsDark'
|
||||||
|
|
||||||
test('dark color', () => {
|
test('dark color', () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {describe, it, expect} from 'vitest'
|
||||||
|
|
||||||
import {filterLabelsByQuery} from './labels'
|
import {filterLabelsByQuery} from './labels'
|
||||||
import {createNewIndexer} from '../indexes'
|
import {createNewIndexer} from '../indexes'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {test, expect} from 'vitest'
|
||||||
|
|
||||||
import {calculateDayInterval} from './calculateDayInterval'
|
import {calculateDayInterval} from './calculateDayInterval'
|
||||||
|
|
||||||
const days = {
|
const days = {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {test, expect} from 'vitest'
|
||||||
|
|
||||||
import {calculateNearestHours} from './calculateNearestHours'
|
import {calculateNearestHours} from './calculateNearestHours'
|
||||||
|
|
||||||
test('5:00', () => {
|
test('5:00', () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {test, expect} from 'vitest'
|
||||||
|
|
||||||
import {createDateFromString} from './createDateFromString'
|
import {createDateFromString} from './createDateFromString'
|
||||||
|
|
||||||
test('YYYY-MM-DD HH:MM', () => {
|
test('YYYY-MM-DD HH:MM', () => {
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
import {test, expect, fn} from 'vitest'
|
||||||
import {getHistory, removeListFromHistory, saveListToHistory} from './listHistory'
|
import {getHistory, removeListFromHistory, saveListToHistory} from './listHistory'
|
||||||
|
|
||||||
test('return an empty history when none was saved', () => {
|
test('return an empty history when none was saved', () => {
|
||||||
Storage.prototype.getItem = jest.fn(() => null)
|
Storage.prototype.getItem = fn(() => null)
|
||||||
const h = getHistory()
|
const h = getHistory()
|
||||||
expect(h).toStrictEqual([])
|
expect(h).toStrictEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('return a saved history', () => {
|
test('return a saved history', () => {
|
||||||
const saved = [{id: 1}, {id: 2}]
|
const saved = [{id: 1}, {id: 2}]
|
||||||
Storage.prototype.getItem = jest.fn(() => JSON.stringify(saved))
|
Storage.prototype.getItem = fn(() => JSON.stringify(saved))
|
||||||
|
|
||||||
const h = getHistory()
|
const h = getHistory()
|
||||||
expect(h).toStrictEqual(saved)
|
expect(h).toStrictEqual(saved)
|
||||||
|
@ -16,8 +17,8 @@ test('return a saved history', () => {
|
||||||
|
|
||||||
test('store list in history', () => {
|
test('store list in history', () => {
|
||||||
let saved = {}
|
let saved = {}
|
||||||
Storage.prototype.getItem = jest.fn(() => null)
|
Storage.prototype.getItem = fn(() => null)
|
||||||
Storage.prototype.setItem = jest.fn((key, lists) => {
|
Storage.prototype.setItem = fn((key, lists) => {
|
||||||
saved = lists
|
saved = lists
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -27,8 +28,8 @@ test('store list in history', () => {
|
||||||
|
|
||||||
test('store only the last 5 lists in history', () => {
|
test('store only the last 5 lists in history', () => {
|
||||||
let saved: string | null = null
|
let saved: string | null = null
|
||||||
Storage.prototype.getItem = jest.fn(() => saved)
|
Storage.prototype.getItem = fn(() => saved)
|
||||||
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
|
Storage.prototype.setItem = fn((key: string, lists: string) => {
|
||||||
saved = lists
|
saved = lists
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -43,8 +44,8 @@ test('store only the last 5 lists in history', () => {
|
||||||
|
|
||||||
test('don\'t store the same list twice', () => {
|
test('don\'t store the same list twice', () => {
|
||||||
let saved: string | null = null
|
let saved: string | null = null
|
||||||
Storage.prototype.getItem = jest.fn(() => saved)
|
Storage.prototype.getItem = fn(() => saved)
|
||||||
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
|
Storage.prototype.setItem = fn((key: string, lists: string) => {
|
||||||
saved = lists
|
saved = lists
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -55,8 +56,8 @@ test('don\'t store the same list twice', () => {
|
||||||
|
|
||||||
test('move a list to the beginning when storing it multiple times', () => {
|
test('move a list to the beginning when storing it multiple times', () => {
|
||||||
let saved: string | null = null
|
let saved: string | null = null
|
||||||
Storage.prototype.getItem = jest.fn(() => saved)
|
Storage.prototype.getItem = fn(() => saved)
|
||||||
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
|
Storage.prototype.setItem = fn((key: string, lists: string) => {
|
||||||
saved = lists
|
saved = lists
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -68,11 +69,11 @@ test('move a list to the beginning when storing it multiple times', () => {
|
||||||
|
|
||||||
test('remove list from history', () => {
|
test('remove list from history', () => {
|
||||||
let saved: string | null = '[{"id": 1}]'
|
let saved: string | null = '[{"id": 1}]'
|
||||||
Storage.prototype.getItem = jest.fn(() => null)
|
Storage.prototype.getItem = fn(() => null)
|
||||||
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
|
Storage.prototype.setItem = fn((key: string, lists: string) => {
|
||||||
saved = lists
|
saved = lists
|
||||||
})
|
})
|
||||||
Storage.prototype.removeItem = jest.fn((key: string) => {
|
Storage.prototype.removeItem = fn((key: string) => {
|
||||||
saved = null
|
saved = null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {describe, it, expect} from 'vitest'
|
||||||
|
|
||||||
import {parseTaskText} from './parseTaskText'
|
import {parseTaskText} from './parseTaskText'
|
||||||
import {getDateFromText, getDateFromTextIn} from '../helpers/time/parseDate'
|
import {getDateFromText, getDateFromTextIn} from '../helpers/time/parseDate'
|
||||||
import {calculateDayInterval} from '../helpers/time/calculateDayInterval'
|
import {calculateDayInterval} from '../helpers/time/calculateDayInterval'
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"types": [
|
"types": [
|
||||||
"jest",
|
|
||||||
"vite/client"
|
"vite/client"
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/// <reference types="vitest" />
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import legacyFn from '@vitejs/plugin-legacy'
|
import legacyFn from '@vitejs/plugin-legacy'
|
||||||
|
@ -27,6 +28,10 @@ if (isModernBuild) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
// https://vitest.dev/config/
|
||||||
|
test: {
|
||||||
|
environment: 'happy-dom',
|
||||||
|
},
|
||||||
css: {
|
css: {
|
||||||
preprocessorOptions: {
|
preprocessorOptions: {
|
||||||
scss: {
|
scss: {
|
Loading…
Reference in a new issue