From 62ad4da0e7af30fc71e1fedad2bc567e41b72c43 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sat, 26 Apr 2025 11:30:37 +0200 Subject: [PATCH] test(markdown-it-plugins): replace jest with vitest Signed-off-by: Tilman Vatteroth --- markdown-it-plugins/.eslintrc.cjs | 12 +-- markdown-it-plugins/jest.config.json | 26 ----- markdown-it-plugins/jest.config.json.license | 3 - markdown-it-plugins/package.json | 11 +-- .../src/image-size/index.test.ts | 2 +- .../__snapshots__/index.test.ts.snap | 68 +++++++++++-- .../src/task-lists/index.test.ts | 2 +- .../src/toc/__snapshots__/index.test.ts.snap | 96 +++++++++++++++++-- markdown-it-plugins/src/toc/index.test.ts | 4 +- yarn.lock | 5 +- 10 files changed, 162 insertions(+), 67 deletions(-) delete mode 100644 markdown-it-plugins/jest.config.json delete mode 100644 markdown-it-plugins/jest.config.json.license diff --git a/markdown-it-plugins/.eslintrc.cjs b/markdown-it-plugins/.eslintrc.cjs index 90db6a39d..7ead0d868 100644 --- a/markdown-it-plugins/.eslintrc.cjs +++ b/markdown-it-plugins/.eslintrc.cjs @@ -13,13 +13,8 @@ module.exports = { }, "plugins": [ "@typescript-eslint", - "jest", "prettier" ], - "env": { - "jest": true, - "jest/globals": true - }, "extends": [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", @@ -30,11 +25,6 @@ module.exports = { "rules": { "prettier/prettier": ["error", require('./.prettierrc.json') - ], - "jest/no-disabled-tests": "warn", - "jest/no-focused-tests": "error", - "jest/no-identical-title": "error", - "jest/prefer-to-have-length": "warn", - "jest/valid-expect": "error" + ] } } diff --git a/markdown-it-plugins/jest.config.json b/markdown-it-plugins/jest.config.json deleted file mode 100644 index 4f95301a0..000000000 --- a/markdown-it-plugins/jest.config.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "testRegex" : "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "testPathIgnorePatterns" : [ - "/dist/" - ], - "moduleFileExtensions" : [ - "ts", - "tsx", - "js" - ], - "extensionsToTreatAsEsm" : [ - ".ts" - ], - "moduleNameMapper" : { - "^(\\.{1,2}/.*)\\.js$" : "$1" - }, - "transform" : { - "^.+\\.tsx?$" : [ - "ts-jest", - { - "tsconfig" : "tsconfig.test.json", - "useESM" : true - } - ] - } -} diff --git a/markdown-it-plugins/jest.config.json.license b/markdown-it-plugins/jest.config.json.license deleted file mode 100644 index c223474fb..000000000 --- a/markdown-it-plugins/jest.config.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - -SPDX-License-Identifier: CC0-1.0 diff --git a/markdown-it-plugins/package.json b/markdown-it-plugins/package.json index d721bc11b..1f9451f5a 100644 --- a/markdown-it-plugins/package.json +++ b/markdown-it-plugins/package.json @@ -86,8 +86,8 @@ ], "scripts": { "build": "./build.sh", - "test": "jest", - "test:ci": "jest --ci", + "test": "vitest", + "test:ci": "vitest --run", "prepublish": "rm -rf dist && yarn lint && yarn build && yarn test", "lint": "eslint src --ext .ts", "lint:fix": "eslint --fix --ext .ts src" @@ -108,19 +108,16 @@ "html-entities": "2.5.2" }, "devDependencies": { - "@jest/types": "29.6.3", "@types/markdown-it": "13.0.8", "@typescript-eslint/eslint-plugin": "8.14.0", "@typescript-eslint/parser": "8.14.0", "eslint": "8.57.1", "eslint-config-prettier": "9.1.0", - "eslint-plugin-jest": "28.9.0", "eslint-plugin-prettier": "5.2.3", - "jest": "29.7.0", "markdown-it": "13.0.2", "prettier": "3.3.3", - "ts-jest": "29.2.5", - "typescript": "5.6.3" + "typescript": "5.6.3", + "vitest": "3.1.2" }, "repository": { "type": "git", diff --git a/markdown-it-plugins/src/image-size/index.test.ts b/markdown-it-plugins/src/image-size/index.test.ts index 18c2c585b..cae8468df 100644 --- a/markdown-it-plugins/src/image-size/index.test.ts +++ b/markdown-it-plugins/src/image-size/index.test.ts @@ -7,7 +7,7 @@ import MarkdownIt from 'markdown-it/lib' import { imageSize } from './index.js' -import { describe, expect, it } from '@jest/globals' +import { describe, expect, it } from 'vitest' describe('markdown-it-imsize', function () { const md = new MarkdownIt({ diff --git a/markdown-it-plugins/src/task-lists/__snapshots__/index.test.ts.snap b/markdown-it-plugins/src/task-lists/__snapshots__/index.test.ts.snap index 347eb5118..f18195bb5 100644 --- a/markdown-it-plugins/src/task-lists/__snapshots__/index.test.ts.snap +++ b/markdown-it-plugins/src/task-lists/__snapshots__/index.test.ts.snap @@ -1,9 +1,65 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: MIT - */ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`markdown-it-task-lists > renders bullet correctly 1`] = ` +" +" +`; + +exports[`markdown-it-task-lists > renders dirty correctly 1`] = ` +" +" +`; + +exports[`markdown-it-task-lists > renders mixedNested correctly 1`] = ` +"

Test 1

+
    +
  1. foo +
      +
    • nested unchecked item 1
    • +
    • not a todo item 2
    • +
    • not a todo item 3
    • +
    • nested checked item 4
    • +
    +
  2. +
  3. bar
  4. +
  5. spam
  6. +
+

Test 2

+ +" +`; + +exports[`markdown-it-task-lists > renders ordered correctly 1`] = ` +"
    +
  1. checked ordered 1
  2. +
  3. unchecked ordered 2
  4. +
  5. checked ordered 3
  6. +
  7. unchecked ordered 4
  8. +
+" +`; exports[`markdown-it-task-lists renders bullet correctly 1`] = ` "