Skip to content

Commit 3d27dd5

Browse files
committed
use vitest, configure eslint and tsconfig properly
1 parent 57af319 commit 3d27dd5

File tree

9 files changed

+792
-1734
lines changed

9 files changed

+792
-1734
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module.exports = {
9090
"@typescript-eslint/no-unused-vars": "warn",
9191
"@typescript-eslint/strict-boolean-expressions": "off",
9292
"@typescript-eslint/restrict-template-expressions": "off",
93+
"@typescript-eslint/no-unsafe-call": "off",
9394
"quote-props": ["error", "as-needed"],
9495
"object-shorthand": ["error", "always"],
9596
"no-unused-vars": "off",

jest.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"build": "cross-env COMMIT_HASH=$(git rev-parse --short HEAD) vite build",
2323
"start": "COMMIT_HASH=$(git rev-parse --short HEAD) vite",
2424
"preview": "vite preview",
25-
"test:unit": "TZ=UTC && jest --ci --runInBand",
25+
"test:unit": "TZ=UTC vitest run",
2626
"test:e2e": "cypress run --spec 'e2e/tests/console/*.spec.js'",
2727
"test:e2e:auth": "cypress run --spec 'e2e/tests/auth/*.spec.js'",
2828
"test:e2e:enterprise": "cypress run --spec 'e2e/tests/enterprise/*.spec.js'",
@@ -111,7 +111,6 @@
111111
"@types/babel__core": "^7",
112112
"@types/draggabilly": "^2.1.6",
113113
"@types/echarts": "^4.9.22",
114-
"@types/jest": "^29.5.14",
115114
"@types/jquery": "3.5.1",
116115
"@types/lodash.merge": "^4.6.9",
117116
"@types/node": "^17.0.41",
@@ -126,7 +125,6 @@
126125
"@typescript-eslint/eslint-plugin": "^7.7.0",
127126
"@typescript-eslint/parser": "^7.7.0",
128127
"@vitejs/plugin-react": "^5.1.0",
129-
"babel-jest": "^29.4.2",
130128
"babel-plugin-import": "^1.13.8",
131129
"babel-plugin-styled-components": "^2.0.7",
132130
"bundlewatch": "^0.3.3",
@@ -144,20 +142,18 @@
144142
"eslint-plugin-react": "7.34.1",
145143
"eslint-plugin-react-hooks": "4.6.0",
146144
"eslint-plugin-standard": "5.0.0",
147-
"jest": "^29.7.0",
148-
"jest-util": "29.7.0",
149145
"prettier": "^2.5.1",
150146
"sass": "^1.93.2",
151147
"stylelint": "^13.13.1",
152148
"stylelint-config-prettier": "8.0.1",
153149
"stylelint-config-recommended": "3.0.0",
154150
"stylelint-config-styled-components": "0.1.1",
155151
"stylelint-processor-styled-components": "1.10.0",
156-
"ts-jest": "^29.2.5",
157152
"typescript": "^5.7.0",
158153
"vite": "^7.1.12",
159154
"vite-plugin-checker": "^0.11.0",
160-
"vite-plugin-static-copy": "^3.1.4"
155+
"vite-plugin-static-copy": "^3.1.4",
156+
"vitest": "^1.6.0"
161157
},
162158
"resolutions": {
163159
"webpack": "^5",

src/js/console/array-equals.test.js renamed to src/js/console/array-equals.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ describe("arrayEquals", () => {
44
const testCases = [
55
[[1, 2, 3], [1, 2, 3], true],
66
[[], [1], false],
7-
]
7+
] as Array<[number[], number[], boolean]>
88

99
testCases.forEach(([left, right, expected]) => {
1010
test(`arrayEquals(${left.toString()}, ${right.toString()})`, () => {
11-
expect(arrayEquals(left, right)).toBe(expected)
11+
expect(arrayEquals(left, right)).toEqual(expected)
1212
})
1313
})
1414
})

src/js/console/array-equals.js renamed to src/js/console/array-equals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function arrayEquals(left, right) {
1+
export function arrayEquals(left: any[], right: any[]): boolean {
22
// if the other array is a falsy value, return
33
if (!left || !right) {
44
return false

src/scenes/Editor/Metrics/utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import {
1414
compactSQL,
1515
} from "./utils"
1616

17+
vi.mock("../../../consts", () => ({
18+
API: "https://alurin.questdb.io",
19+
API_VERSION: "2",
20+
BUTTON_ICON_SIZE: "26px",
21+
}))
22+
1723
describe("getAutoRefreshRate", () => {
1824
it("should set a correct auto refresh rate for relative periods", () => {
1925
expect(getAutoRefreshRate("now-5m", "now")).toBe("5s")

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"target": "es5",
1818
"baseUrl": "./src",
1919
"rootDir": "./src",
20-
"types": ["vite/client"]
20+
"types": ["vite/client", "vitest/globals"]
2121
},
2222
"include": ["src", "src/vite-env.d.ts"],
23-
"exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.test.js", "**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js", "node_modules"]
23+
"exclude": ["node_modules"]
2424
}

vite.config.ts renamed to vite.config.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defineConfig, loadEnv } from 'vite'
1+
import { defineConfig } from 'vite'
2+
import { loadEnv } from 'vite'
23
import react from '@vitejs/plugin-react'
34
import { checker } from 'vite-plugin-checker'
45
import { viteStaticCopy } from 'vite-plugin-static-copy'
@@ -112,6 +113,12 @@ export default defineConfig(({ mode }) => {
112113
'import.meta.env.COMMIT_HASH': JSON.stringify(env.COMMIT_HASH || ''),
113114
},
114115

116+
test: {
117+
environment: 'node',
118+
include: 'src/**/*.(test|spec).(ts|tsx|js|jsx)',
119+
globals: true,
120+
},
121+
115122
server: {
116123
host: 'localhost',
117124
port: 9999,
@@ -156,3 +163,5 @@ export default defineConfig(({ mode }) => {
156163
},
157164
}
158165
})
166+
167+

0 commit comments

Comments
 (0)