Skip to content

Commit 2890b86

Browse files
committed
configure vitest
1 parent 0001fc7 commit 2890b86

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"scripts": {
1717
"dev": "vite",
1818
"build": "vite build",
19-
"preview": "vite preview"
19+
"preview": "vite preview",
20+
"test": "vitest"
2021
},
2122
"devDependencies": {
2223
"shadow-cljs": "^2.23.8",

test/lang-clojure-eval.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { assert, expect, test } from 'vitest'
2+
3+
// Edit an assertion and save to see HMR in action
4+
5+
test('Math.sqrt()', () => {
6+
expect(Math.sqrt(4)).toBe(2)
7+
expect(Math.sqrt(144)).toBe(12)
8+
expect(Math.sqrt(2)).toBe(Math.SQRT2)
9+
})
10+
11+
test('JSON', () => {
12+
const input = {
13+
foo: 'hello',
14+
bar: 'world',
15+
}
16+
17+
const output = JSON.stringify(input)
18+
19+
expect(output).eq('{"foo":"hello","bar":"world"}')
20+
assert.deepEqual(JSON.parse(output), input, 'matches original')
21+
})

vite.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { defineConfig } from "vite";
22

33
export default defineConfig({
4-
base: '/lang-clojure-eval/'
4+
base: '/lang-clojure-eval/',
5+
test: {
6+
/* for example, use global to avoid globals imports (describe, test, expect): */
7+
// globals: true,
8+
}
59
})

0 commit comments

Comments
 (0)