From cb5d6f07f79c4ef90df03e0d1981ebee3dc7aa3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e?= Date: Fri, 13 Jan 2023 09:58:24 +0100 Subject: [PATCH] Use vitest (#108) --- .github/workflows/ci.yml | 4 ++-- package.json | 13 +++++++------ test/index.js => src/index.test.js | 5 +++-- src/index.ts | 2 +- vite.config.ts | 7 +++++++ 5 files changed, 20 insertions(+), 11 deletions(-) rename test/index.js => src/index.test.js (98%) create mode 100644 vite.config.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06c5a93..1b67ca5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: name: Tests strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x, 19.x] runs-on: ubuntu-latest steps: - name: Checkout sources @@ -35,7 +35,7 @@ jobs: - name: Run tests run: npm run tests-only - name: Submit coverage - if: matrix.node-version == '16.x' + if: matrix.node-version == '18.x' uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{secrets.GITHUB_TOKEN}} diff --git a/package.json b/package.json index d435d9f..03a4ee6 100644 --- a/package.json +++ b/package.json @@ -23,18 +23,19 @@ "scripts": { "prepare": "rollup -c", "lint": "eslint .", - "test": "npm run prepare && npm run tests-only && npm run lint", - "tests-only": "jest --testMatch '**/test/*.js' --coverage" + "test": "npm run tests-only && npm run lint", + "tests-only": "vitest run --coverage" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/parser": "^5.3.0", + "@vitest/coverage-c8": "^0.27.1", "eslint": "^8.2.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.22.0", - "jest": "^29.2.0", - "rollup": "^3.2.2", - "rollup-plugin-typescript2": "^0.34.0", - "typescript": "^4.0.2" + "rollup": "^3.8.1", + "rollup-plugin-typescript2": "^0.34.1", + "typescript": "^4.0.2", + "vitest": "^0.27.1" } } diff --git a/test/index.js b/src/index.test.js similarity index 98% rename from test/index.js rename to src/index.test.js index 0e5478d..c0d4bae 100644 --- a/test/index.js +++ b/src/index.test.js @@ -1,5 +1,6 @@ -const assert = require('assert'); -const parseChatMarkup = require('..').default; +import assert from 'assert'; +import { describe, it } from 'vitest'; +import parseChatMarkup from './index.ts'; describe('parseChatMarkup', () => { const bareOptions = {}; diff --git a/src/index.ts b/src/index.ts index 6e01044..b180c3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -297,7 +297,7 @@ export default function parse(message: string, options: MarkupOptions = {}): Mar return { type: 'link', text: token.text, href: httpify(token.text) }; case TokenType.Text: return token.text; - /* istanbul ignore next */ + /* c8 ignore next 2 */ default: throw new Error('unreachable'); } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..8e1b4cf --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,7 @@ +export default { + test: { + coverage: { + reporter: ['text', 'lcov', 'html'], + }, + }, +};