Skip to content

Commit c755193

Browse files
committed
Stop using Vitest globals
Vitest provides globals primarily to make the transition from Jest more smooth. But importing its functions explicitly is considered a better pattern, and we have so few tests right now that it's trivial to migrate them all.
1 parent f79ca02 commit c755193

9 files changed

+8
-5
lines changed

src/Toast.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { vi } from "vitest";
17+
import { expect, test, vi } from "vitest";
1818
import { screen, render } from "@testing-library/react";
1919
import userEvent from "@testing-library/user-event";
2020

src/UrlParams.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { vi } from "vitest";
17+
import { beforeAll, describe, expect, it, vi } from "vitest";
1818

1919
import { getRoomIdentifierFromUrl } from "../src/UrlParams";
2020
import { Config } from "../src/config/Config";

src/home/CallList.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
import { render, RenderResult } from "@testing-library/react";
1818
import { MatrixClient } from "matrix-js-sdk";
1919
import { MemoryRouter } from "react-router-dom";
20+
import { describe, expect, it } from "vitest";
2021

2122
import { CallList } from "../../src/home/CallList";
2223
import { GroupCallRoom } from "../../src/home/useGroupCallRooms";

src/initializer.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
import { expect, test } from "vitest";
18+
1719
import { Initializer } from "../src/initializer";
1820

1921
test("initBeforeReact sets font family from URL param", () => {

src/otel/ObjectFlattener.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ByteSentStatsReport,
2121
ConnectionStatsReport,
2222
} from "matrix-js-sdk/src/webrtc/stats/statsReport";
23+
import { describe, expect, it } from "vitest";
2324

2425
import { ObjectFlattener } from "../../src/otel/ObjectFlattener";
2526

src/room/checkForParallelCalls.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { vi, Mocked } from "vitest";
17+
import { vi, Mocked, test, expect } from "vitest";
1818
import { RoomState } from "matrix-js-sdk/src/models/room-state";
1919

2020
import { PosthogAnalytics } from "../../src/analytics/PosthogAnalytics";

src/rtcSessionHelper.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
18+
import { expect, test, vi } from "vitest";
1819

1920
import { enterRTCSession } from "../src/rtcSessionHelpers";
2021
import { Config } from "../src/config/Config";

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
},
4747
"include": [
4848
"./node_modules/matrix-js-sdk/src/@types/*.d.ts",
49-
"./node_modules/vitest/globals.d.ts",
5049
"./src/**/*.ts",
5150
"./src/**/*.tsx"
5251
]

vitest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default defineConfig((configEnv) =>
66
viteConfig(configEnv),
77
defineConfig({
88
test: {
9-
globals: true,
109
environment: "jsdom",
1110
css: {
1211
modules: {

0 commit comments

Comments
 (0)