Replace Jest with Vitest

This commit is contained in:
Niels van Velzen 2023-10-03 16:20:47 +02:00
parent ac1cc7fafc
commit 12371b4bcb
7 changed files with 407 additions and 3250 deletions

View File

@ -25,8 +25,5 @@ jobs:
- name: Install dependencies
run: npm ci --no-audit
- name: Build for production
run: npm run build
- name: Run tests
run: npm run test

View File

@ -1,7 +0,0 @@
module.exports = {
globals: {
RECEIVERVERSION: 'thisIsVersionNumber'
},
preset: 'ts-jest',
testEnvironment: 'jsdom'
};

3627
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@
},
"devDependencies": {
"@types/chromecast-caf-receiver": "6.0.10",
"@types/jest": "29.5.5",
"@typescript-eslint/eslint-plugin": "6.7.3",
"@typescript-eslint/parser": "6.7.3",
"eslint": "8.50.0",
@ -22,14 +21,12 @@
"eslint-plugin-json": "3.1.0",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-promise": "6.1.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"prettier": "3.0.3",
"stylelint": "15.10.3",
"stylelint-config-standard": "34.0.0",
"ts-jest": "29.1.1",
"typescript": "5.2.2",
"vite": "4.4.9"
"vite": "4.4.9",
"vitest": "0.34.6"
},
"homepage": "https://jellyfin.org/",
"license": "GPL-2.0-or-later",
@ -40,7 +37,7 @@
"scripts": {
"start": "vite",
"build": "vite build",
"test": "jest --silent",
"test": "vitest",
"lint": "npm run lint:code && npm run lint:css && npm run prettier",
"lint:code": "eslint --ext .ts,.js,.json .",
"lint:css": "stylelint src/**/*.css",

View File

@ -1,3 +1,5 @@
import { describe, beforeEach, test, expect } from 'vitest';
import {
credentialManager,
ServerCredential

View File

@ -1,4 +1,6 @@
import { describe, beforeAll, beforeEach, test, expect } from 'vitest';
import { JellyfinApi } from '../jellyfinApi';
import { version } from '../../../package.json';
const setupMockCastSenders = (): void => {
const getSenders = (): Array<any> => [{ id: 'thisIsSenderId' }]; // eslint-disable-line @typescript-eslint/no-explicit-any
@ -213,7 +215,7 @@ describe('getting security headers', () => {
// @ts-expect-error Since the method is private.
const result = JellyfinApi.getSecurityHeaders();
const correctAuth = `MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="thisIsVersionNumber", DeviceId="${btoa(
const correctAuth = `MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="${version}", DeviceId="${btoa(
'thisIsReceiverName'
)}", Device="thisIsReceiverName"`;
@ -231,8 +233,7 @@ describe('getting security headers', () => {
// @ts-expect-error Since the method is private.
const result = JellyfinApi.getSecurityHeaders();
const correct = {
Authorization:
'MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="thisIsVersionNumber", DeviceId="thisIsSenderId", Device="Google%20Cast"'
Authorization: `MediaBrowser Client="Chromecast", Token="thisIsAccessToken", Version="${version}", DeviceId="thisIsSenderId", Device="Google%20Cast"`
};
expect(result).toMatchObject(correct);

View File

@ -14,6 +14,6 @@
"paths": {
"~/*": ["./*"]
},
"types": ["@types/chromecast-caf-receiver", "jest", "vite/client"]
"types": ["@types/chromecast-caf-receiver", "vite/client"]
}
}