back to jest, currently has the best experience

This commit is contained in:
MapleLeaf
2021-12-21 10:10:53 -06:00
parent e2ea46a18f
commit f0a2e56b26
5 changed files with 1932 additions and 273 deletions

18
jest.config.js Normal file
View File

@@ -0,0 +1,18 @@
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
transform: {
"^.+\\.tsx?$": [
"esbuild-jest",
{
format: "esm",
sourcemap: true,
},
],
},
moduleNameMapper: {
"(^\\./.+)\\.js$": "$1",
},
extensionsToTreatAsEsm: [".ts", ".tsx"],
}
export default config

View File

@@ -17,8 +17,8 @@
"lint": "eslint --ext js,ts,tsx .",
"lint-fix": "pnpm lint -- --fix",
"format": "prettier --write .",
"test": "vitest",
"coverage": "vitest --coverage",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"coverage": "pnpm test -- --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
@@ -34,10 +34,15 @@
},
"devDependencies": {
"@itsmapleleaf/configs": "^1.1.2",
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"c8": "^7.10.0",
"chai": "^4.3.4",
"discord.js": "^13.3.1",
"dotenv": "^10.0.0",
"esbuild": "^0.14.6",
"esbuild-jest": "^0.5.0",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
@@ -46,17 +51,13 @@
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unicorn": "^39.0.0",
"prettier": "^2.5.1",
"should": "^13.2.3",
"typescript": "^4.5.4",
"vite": "^2.7.4",
"vitest": "^0.0.102",
"discord.js": "^13.3.1",
"dotenv": "^10.0.0",
"esbuild": "^0.14.6",
"jest": "^27.4.5",
"nanoid": "^3.1.30",
"prettier": "^2.5.1",
"react": "^17.0.2",
"tsup": "^5.11.6"
"should": "^13.2.3",
"tsup": "^5.11.6",
"typescript": "^4.5.4"
},
"eslintConfig": {
"extends": [

2156
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
import { expect, test } from "vitest"
import { createDeferred } from "./deferred.js"
import { createDeferred } from "./deferred"
test("resolve", async () => {
const deferred = createDeferred<string>()

View File

@@ -1,9 +1,7 @@
/* eslint-disable unicorn/no-null */
import type { Message } from "discord.js"
import { Client, TextChannel } from "discord.js"
import { deepEqual } from "node:assert"
import React from "react"
import { afterAll, beforeAll, test } from "vitest"
import { pick } from "./helpers/pick.js"
import { raise } from "./helpers/raise.js"
import type { ReacordRoot } from "./main"
@@ -150,8 +148,7 @@ function extractMessageData(message: Message) {
async function assertMessages(expected: Array<DeepPartial<MessageData>>) {
const messages = await channel.messages.fetch()
deepEqual(
messages.map((message) => extractMessageData(message)),
expect(messages.map((message) => extractMessageData(message))).toEqual(
expected.map((message) => ({
content: "",
...message,