Skip to content

Commit bbbd245

Browse files
authored
gut jest from ott-common (#1327)
1 parent 01d0cce commit bbbd245

12 files changed

+90
-41
lines changed

common/package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"build": "tsc",
99
"lint": "tsc --noEmit && eslint --ext .js,.ts --fix .",
1010
"lint-ci": "tsc --noEmit && eslint .",
11-
"test": "jest --config ./tests/unit/jest.config.js -experimental-vm-modules --runInBand --detectOpenHandles --forceExit --coverage"
11+
"test": "vitest run --coverage"
12+
},
13+
"dependencies": {
14+
"dayjs": "^1.10.4"
15+
},
16+
"devDependencies": {
17+
"eslint-plugin-vitest": "0.3.22",
18+
"vitest": "^1.2.2"
1219
}
13-
}
20+
}

common/tests/unit/.eslintrc.json

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
{
2-
"env": {
3-
"jest": true
4-
},
5-
"plugins": ["jest"],
2+
"extends": ["plugin:vitest/recommended"],
3+
"plugins": ["vitest"],
64
"rules": {
75
"no-console": "off",
86
"@typescript-eslint/no-empty-function": "off",
97
"@typescript-eslint/require-await": "off",
108
"@typescript-eslint/no-floating-promises": "off",
119

12-
"jest/consistent-test-it": ["error", { "fn": "it" }],
13-
"jest/expect-expect": "warn",
14-
"jest/no-duplicate-hooks": "error",
15-
"jest/no-focused-tests": "error",
16-
"jest/no-identical-title": "error",
17-
"jest/no-if": "error",
18-
"jest/no-expect-resolves": "error",
19-
"jest/no-export": "error",
20-
"jest/no-standalone-expect": "error",
21-
"jest/no-truthy-falsy": "error",
22-
"jest/prefer-spy-on": "error",
23-
"jest/require-top-level-describe": "warn"
10+
"vitest/consistent-test-it": ["error", { "fn": "it" }],
11+
"vitest/expect-expect": "warn",
12+
"vitest/no-duplicate-hooks": "error",
13+
"vitest/no-focused-tests": "error",
14+
"vitest/no-identical-title": "error",
15+
"vitest/no-conditional-tests": "error",
16+
"vitest/no-standalone-expect": "error",
17+
"vitest/prefer-spy-on": "error",
18+
"vitest/require-top-level-describe": "warn"
2419
}
2520
}

common/tests/unit/jest.config.js

-22
This file was deleted.

common/tests/unit/permissions.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { PermissionDeniedException } from "../../exceptions";
23
import { Role } from "../../models/types";
34
import permissions, { Grants, GrantMask } from "../../permissions";

common/tests/unit/queueexport.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { exportQueue } from "../../queueexport";
23
import type { QueueItem } from "../../models/video";
34

common/tests/unit/result.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { Result, ok, err, intoResult, intoResultAsync } from "../../result";
23

34
describe("Result", () => {

common/tests/unit/serialize.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { deserializeMap, deserializeSet, replacer } from "../../serialize";
23

34
describe("Serialize helpers", () => {

common/tests/unit/timestamp.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { describe, it, expect } from "vitest";
12
import dayjs from "dayjs";
23
import { calculateCurrentPosition } from "../../timestamp";
34

4-
// TODO: move this to ott-common
55
describe("calculateCurrentPosition", () => {
66
it("should calculate the correct playback position", () => {
77
expect(calculateCurrentPosition(dayjs(), dayjs(), 0)).toBeCloseTo(0);

common/tests/unit/userutils.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { canKickUser } from "../../userutils";
23
import { Role } from "../../models/types";
34

common/tests/unit/voteskip.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { Grants, parseIntoGrantMask } from "../../permissions";
23
import { PlayerStatus, Role, RoomUserInfo } from "../../models/types";
34
import { voteSkipThreshold, countEligibleVoters } from "../../voteskip";

common/vitest.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="vitest" />
2+
import { defineConfig, configDefaults } from "vitest/config";
3+
4+
export default defineConfig({
5+
test: {
6+
exclude: [...configDefaults.exclude, "ts-out"],
7+
},
8+
});

yarn.lock

+55
Original file line numberDiff line numberDiff line change
@@ -4315,6 +4315,14 @@
43154315
"@typescript-eslint/types" "6.19.0"
43164316
"@typescript-eslint/visitor-keys" "6.19.0"
43174317

4318+
"@typescript-eslint/[email protected]":
4319+
version "6.21.0"
4320+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz#ea8a9bfc8f1504a6ac5d59a6df308d3a0630a2b1"
4321+
integrity sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==
4322+
dependencies:
4323+
"@typescript-eslint/types" "6.21.0"
4324+
"@typescript-eslint/visitor-keys" "6.21.0"
4325+
43184326
"@typescript-eslint/[email protected]":
43194327
version "5.59.9"
43204328
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz#53bfaae2e901e6ac637ab0536d1754dfef4dafc2"
@@ -4365,6 +4373,11 @@
43654373
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.19.0.tgz#689b0498c436272a6a2059b09f44bcbd90de294a"
43664374
integrity sha512-lFviGV/vYhOy3m8BJ/nAKoAyNhInTdXpftonhWle66XHAtT1ouBlkjL496b5H5hb8dWXHwtypTqgtb/DEa+j5A==
43674375

4376+
"@typescript-eslint/[email protected]":
4377+
version "6.21.0"
4378+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.21.0.tgz#205724c5123a8fef7ecd195075fa6e85bac3436d"
4379+
integrity sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==
4380+
43684381
"@typescript-eslint/[email protected]":
43694382
version "2.34.0"
43704383
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5"
@@ -4431,6 +4444,20 @@
44314444
semver "^7.5.4"
44324445
ts-api-utils "^1.0.1"
44334446

4447+
"@typescript-eslint/[email protected]":
4448+
version "6.21.0"
4449+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz#c47ae7901db3b8bddc3ecd73daff2d0895688c46"
4450+
integrity sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==
4451+
dependencies:
4452+
"@typescript-eslint/types" "6.21.0"
4453+
"@typescript-eslint/visitor-keys" "6.21.0"
4454+
debug "^4.3.4"
4455+
globby "^11.1.0"
4456+
is-glob "^4.0.3"
4457+
minimatch "9.0.3"
4458+
semver "^7.5.4"
4459+
ts-api-utils "^1.0.1"
4460+
44344461
"@typescript-eslint/[email protected]":
44354462
version "5.59.9"
44364463
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.9.tgz#adee890107b5ffe02cd46fdaa6c2125fb3c6c7c4"
@@ -4485,6 +4512,19 @@
44854512
"@typescript-eslint/typescript-estree" "6.19.0"
44864513
semver "^7.5.4"
44874514

4515+
"@typescript-eslint/utils@^6.21.0":
4516+
version "6.21.0"
4517+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.21.0.tgz#4714e7a6b39e773c1c8e97ec587f520840cd8134"
4518+
integrity sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==
4519+
dependencies:
4520+
"@eslint-community/eslint-utils" "^4.4.0"
4521+
"@types/json-schema" "^7.0.12"
4522+
"@types/semver" "^7.5.0"
4523+
"@typescript-eslint/scope-manager" "6.21.0"
4524+
"@typescript-eslint/types" "6.21.0"
4525+
"@typescript-eslint/typescript-estree" "6.21.0"
4526+
semver "^7.5.4"
4527+
44884528
"@typescript-eslint/[email protected]":
44894529
version "5.59.9"
44904530
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz#9f86ef8e95aca30fb5a705bb7430f95fc58b146d"
@@ -4517,6 +4557,14 @@
45174557
"@typescript-eslint/types" "6.19.0"
45184558
eslint-visitor-keys "^3.4.1"
45194559

4560+
"@typescript-eslint/[email protected]":
4561+
version "6.21.0"
4562+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz#87a99d077aa507e20e238b11d56cc26ade45fe47"
4563+
integrity sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==
4564+
dependencies:
4565+
"@typescript-eslint/types" "6.21.0"
4566+
eslint-visitor-keys "^3.4.1"
4567+
45204568
"@videojs/[email protected]":
45214569
version "2.16.0"
45224570
resolved "https://registry.yarnpkg.com/@videojs/http-streaming/-/http-streaming-2.16.0.tgz#47f86e793fc773db26dbd9aeb3e5130b767c78fa"
@@ -7784,6 +7832,13 @@ eslint-plugin-react@^7.33.2:
77847832
semver "^6.3.1"
77857833
string.prototype.matchall "^4.0.8"
77867834

7835+
7836+
version "0.3.22"
7837+
resolved "https://registry.yarnpkg.com/eslint-plugin-vitest/-/eslint-plugin-vitest-0.3.22.tgz#207eb4630768f6400cd91a6df23688e8a1fd0898"
7838+
integrity sha512-atkFGQ7aVgcuSeSMDqnyevIyUpfBPMnosksgEPrKE7Y8xQlqG/5z2IQ6UDau05zXaaFv7Iz8uzqvIuKshjZ0Zw==
7839+
dependencies:
7840+
"@typescript-eslint/utils" "^6.21.0"
7841+
77877842
77887843
version "9.7.0"
77897844
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-9.7.0.tgz#d391b9864f128ea2d1ee4dabeafb5f7c0cea981f"

0 commit comments

Comments
 (0)