Skip to content

Commit c287a01

Browse files
committed
chore: migrate from 'uvu' to 'ava' test runner
1 parent 80571e1 commit c287a01

29 files changed

+809
-182
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
"devDependencies": {
1919
"@crashmax/prettier-config": "3.0.1",
2020
"@crashmax/tsconfig": "1.0.2",
21+
"ava": "5.2.0",
2122
"cross-env": "7.0.3",
2223
"nodemon": "2.0.20",
2324
"ts-node": "10.9.1",
2425
"tsup": "6.6.3",
2526
"tsx": "3.12.3",
2627
"turbo": "1.8.1",
27-
"typescript": "4.9.5",
28-
"uvu": "0.5.6"
28+
"typescript": "4.9.5"
2929
},
3030
"engines": {
3131
"node": ">=14.16"

packages/browser/package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"name": "@stenodb/browser",
33
"description": "✍ Easy to use local JSON database",
4+
"type": "module",
45
"version": "3.4.1",
56
"exports": {
67
".": {
78
"types": "./dist/index.d.ts",
89
"require": "./dist/index.js",
9-
"default": "./dist/index.mjs"
10+
"default": "./dist/index.js"
1011
}
1112
},
1213
"types": "./dist/index.d.ts",
1314
"main": "./dist/index.js",
14-
"module": "./dist/index.mjs",
15+
"module": "./dist/index.js",
1516
"files": [
1617
"dist",
1718
"src"
@@ -52,6 +53,16 @@
5253
"peerDependencies": {
5354
"@stenodb/logger": "workspace:3.4.1"
5455
},
56+
"ava": {
57+
"snapshotDir": "test/snapshots",
58+
"extensions": {
59+
"ts": "module"
60+
},
61+
"nodeArguments": [
62+
"--loader=ts-node/esm",
63+
"--no-warnings"
64+
]
65+
},
5566
"engines": {
5667
"node": ">=14.16"
5768
}

packages/fastify/package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "@stenodb/fastify",
33
"version": "3.4.1",
4+
"type": "module",
45
"exports": {
56
".": {
67
"types": "./dist/index.d.ts",
78
"require": "./dist/index.js",
8-
"default": "./dist/index.mjs"
9+
"default": "./dist/index.js"
910
}
1011
},
1112
"types": "./dist/index.d.ts",
1213
"main": "./dist/index.js",
13-
"module": "./dist/index.mjs",
14+
"module": "./dist/index.js",
1415
"files": [
1516
"dist",
1617
"src"
@@ -32,6 +33,16 @@
3233
"@stenodb/node": "workspace:3.4.1",
3334
"fastify": "^4.0.0"
3435
},
36+
"ava": {
37+
"snapshotDir": "test/snapshots",
38+
"extensions": {
39+
"ts": "module"
40+
},
41+
"nodeArguments": [
42+
"--loader=ts-node/esm",
43+
"--no-warnings"
44+
]
45+
},
3546
"engines": {
3647
"node": ">=14.16"
3748
}

packages/lodash/package.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@stenodb/lodash",
33
"version": "3.4.1",
4+
"type": "module",
45
"exports": {
56
".": {
67
"types": "./dist/index.d.ts",
78
"require": "./dist/index.js",
8-
"default": "./dist/index.mjs"
9+
"default": "./dist/index.js"
910
},
1011
"./node": {
1112
"types": "./dist/node.d.ts",
@@ -20,16 +21,16 @@
2021
},
2122
"types": "./dist/index.d.ts",
2223
"main": "./dist/index.js",
23-
"module": "./dist/index.mjs",
24+
"module": "./dist/index.js",
2425
"files": [
2526
"dist",
2627
"src"
2728
],
2829
"scripts": {
2930
"dev": "pnpm build --watch src",
3031
"build": "tsup src/index.ts src/node.ts src/browser.ts --format esm,cjs --dts --clean",
31-
"test": "tsx src/index.test.ts",
32-
"test:watch": "tsx watch src/index.test.ts"
32+
"test": "ava",
33+
"test:watch": "ava --watch"
3334
},
3435
"dependencies": {
3536
"@stenodb/browser": "workspace:3.4.1",
@@ -46,6 +47,16 @@
4647
"@types/lodash": "^4.14.191",
4748
"lodash": "^4.17.21"
4849
},
50+
"ava": {
51+
"snapshotDir": "test/snapshots",
52+
"extensions": {
53+
"ts": "module"
54+
},
55+
"nodeArguments": [
56+
"--loader=ts-node/esm",
57+
"--no-warnings"
58+
]
59+
},
4960
"engines": {
5061
"node": ">=14.16"
5162
}

packages/lodash/src/index.test.ts

-2
This file was deleted.

packages/lodash/src/browser.test.ts renamed to packages/lodash/test/browser.test.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BrowserProvider, LocalStorage } from '@stenodb/browser'
2-
import { test } from 'uvu'
3-
import * as assert from 'uvu/assert'
4-
import { BrowserLodash } from './browser.js'
2+
import test from 'ava'
3+
import { BrowserLodash } from '../src/browser.js'
54

65
const storage = new Map<string, string>()
76
const mockStorage = () => ({
@@ -32,23 +31,21 @@ class User {
3231
}
3332
}
3433

35-
test('BrowserLodash', () => {
34+
test('BrowserLodash', (t) => {
3635
const user1 = new User(1, 'John')
3736
const user2 = new User(2, 'Alice')
3837
const adapter = new LocalStorage('users', User, user1)
3938
const provider = new BrowserProvider()
4039
const db = new BrowserLodash(provider.create(adapter))
4140

4241
db.read()
43-
assert.equal(db.data.value(), user1)
42+
t.deepEqual(db.data.value(), user1)
4443

4544
db.write(user2)
46-
assert.equal(db.data.value(), user2)
45+
t.deepEqual(db.data.value(), user2)
4746

4847
db.reset()
49-
assert.equal(db.data.value(), user1)
50-
assert.is(db.data.get('id').value(), 1)
51-
assert.is(db.data.get('name').value(), 'John')
48+
t.deepEqual(db.data.value(), user1)
49+
t.is(db.data.get('id').value(), 1)
50+
t.is(db.data.get('name').value(), 'John')
5251
})
53-
54-
test.run()
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { dirname, resolve } from 'node:path'
22
import { fileURLToPath } from 'node:url'
33
import { AsyncAdapter, NodeProvider } from '@stenodb/node'
4-
import { test } from 'uvu'
5-
import * as assert from 'uvu/assert'
6-
import { NodeLodash } from './node.js'
4+
import test from 'ava'
5+
import { NodeLodash } from '../src/node.js'
76

87
const provider = new NodeProvider({
98
path: resolve(dirname(fileURLToPath(import.meta.url)), '..', 'db')
@@ -19,7 +18,7 @@ class User {
1918
}
2019
}
2120

22-
test('NodeLodash', async () => {
21+
test('NodeLodash', async (t) => {
2322
const adapter = new AsyncAdapter('users', User)
2423
const db = new NodeLodash(await provider.create(adapter))
2524
const user1 = new User(1, 'John')
@@ -29,12 +28,10 @@ test('NodeLodash', async () => {
2928
await db.write(user1)
3029
}
3130

32-
assert.equal(db.data.value(), user1)
33-
assert.is(db.data.get('id').value(), 1)
34-
assert.is(db.data.get('name').value(), 'John')
31+
t.deepEqual(db.data.value(), user1)
32+
t.is(db.data.get('id').value(), 1)
33+
t.is(db.data.get('name').value(), 'John')
3534

3635
await db.write(user2)
37-
assert.equal(db.data.value(), user2)
36+
t.deepEqual(db.data.value(), user2)
3837
})
39-
40-
test.run()

packages/logger/package.json

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
{
22
"name": "@stenodb/logger",
33
"version": "3.4.1",
4+
"type": "module",
45
"exports": {
56
".": {
67
"types": "./dist/index.d.ts",
78
"require": "./dist/index.js",
8-
"default": "./dist/index.mjs"
9+
"default": "./dist/index.js"
910
},
1011
"./rotation": {
1112
"types": "./dist/rotation.d.ts",
1213
"require": "./dist/rotation.js",
13-
"default": "./dist/rotation.mjs"
14+
"default": "./dist/rotation.js"
1415
}
1516
},
1617
"types": "./dist/index.d.ts",
1718
"main": "./dist/index.js",
18-
"module": "./dist/index.mjs",
19+
"module": "./dist/index.js",
1920
"files": [
2021
"dist",
2122
"src"
2223
],
2324
"scripts": {
2425
"dev": "pnpm build --watch src",
2526
"build": "tsup src/index.ts src/rotation.ts --format esm,cjs --dts --clean",
26-
"test": "tsx src/index.test.ts",
27-
"test:watch": "tsx watch src/index.test.ts"
27+
"test": "ava",
28+
"test:watch": "ava --watch"
2829
},
2930
"dependencies": {
3031
"rotating-file-stream": "3.0.4",
@@ -33,6 +34,16 @@
3334
"devDependencies": {
3435
"@types/node": "18.11.19"
3536
},
37+
"ava": {
38+
"snapshotDir": "test/snapshots",
39+
"extensions": {
40+
"ts": "module"
41+
},
42+
"nodeArguments": [
43+
"--loader=ts-node/esm",
44+
"--no-warnings"
45+
]
46+
},
3647
"engines": {
3748
"node": ">=14.16"
3849
}

packages/logger/src/index.test.ts

-50
This file was deleted.

packages/logger/test/index.test.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { existsSync } from 'node:fs'
2+
import { rm } from 'node:fs/promises'
3+
import { resolve } from 'node:path'
4+
import test from 'ava'
5+
import { Logger } from 'tslog'
6+
import { createLogger } from '../src/logger.js'
7+
import { createRotation } from '../src/rotation.js'
8+
9+
const logsPath = resolve('logs')
10+
11+
test.before(async () => {
12+
if (existsSync(logsPath)) {
13+
await rm(logsPath, { recursive: true })
14+
}
15+
})
16+
17+
test('createLogger', (t) => {
18+
const logger = createLogger({ type: 'pretty' })('test')
19+
t.true(logger instanceof Logger)
20+
t.assert(logger.settings.type, 'pretty')
21+
})
22+
23+
test('createRotation', async (t) => {
24+
const rotation = createRotation({
25+
path: 'logs',
26+
size: '10M',
27+
interval: '1d',
28+
compress: 'gzip'
29+
})
30+
31+
const logger = createLogger({
32+
type: 'hidden',
33+
rotation
34+
})('test-rotation')
35+
36+
t.true(typeof rotation === 'function')
37+
t.true(logger instanceof Logger)
38+
})

packages/nest/package.json

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@
5252
"peerDependencies": {
5353
"@nestjs/common": "^9.0.0"
5454
},
55+
"ava": {
56+
"snapshotDir": "test/snapshots",
57+
"extensions": {
58+
"ts": "commonjs"
59+
},
60+
"nodeArguments": [
61+
"--loader=ts-node/register",
62+
"--no-warnings"
63+
]
64+
},
5565
"engines": {
5666
"node": ">=14.16"
5767
}

0 commit comments

Comments
 (0)