Skip to content

Commit

Permalink
chore: use vitest until fetch can be mocked with bun etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Jun 26, 2024
1 parent b5d477a commit f6354bc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
run: bun install --frozen-lockfile

- name: Test
run: bun test --coverage
run: bun run test:cov
Binary file modified bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"format": "prettier . --check",
"format:fix": "npm run format -- --write",
"test": "vitest run",
"test:watch": "vitest",
"test:cov": "vitest run --coverage",
"dev": "run-p -rl vite:watch serve:firefox",
"vite:site": "vite",
"vite:watch": "vite build --watch --mode development --minify false",
Expand All @@ -32,13 +34,15 @@
"@types/leaflet": "^1.9.12",
"@types/leaflet-fullscreen": "^1.0.9",
"@types/webextension-polyfill": "^0.10.7",
"@vitest/coverage-v8": "^1.6.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
"release-it": "^17.4.0",
"release-it-changelogen": "^0.1.0",
"typescript": "^5.5.2",
"vite": "^5.3.1",
"vite-plugin-static-copy": "^1.0.5",
"vitest": "^1.6.0",
"web-ext": "^8.2.0",
"webextension-polyfill": "^0.12.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/map/utils/parseDMS.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'bun:test'
import { describe, it, expect } from 'vitest'
import { parseDMS } from '../../../src/map/utils/parseDMS'

describe('Parse Degrees Minutes Seconds Direction', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/map/utils/parsePB.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'bun:test'
import { describe, it, expect } from 'vitest'
import { parsePB, tileTypes } from '../../../src/map/utils/parsePB'

describe('Parse PB', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/map/utils/read.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, jest } from 'bun:test'
import { describe, it, expect, vitest } from 'vitest'
import { readPB, readQ, nominatimQ } from '../../../src/map/utils/read'

globalThis.fetch = jest.fn()
globalThis.fetch = vitest.fn()

const input = 'test position'
const result = [{ lat: '1.1', lon: '1.1' }]
Expand Down
2 changes: 1 addition & 1 deletion test/map/utils/zoom.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'bun:test'
import { describe, it, expect } from 'vitest'
import { getMapZoom } from '../../../src/map/utils/zoom'

describe('Zoom levels', () => {
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vitest" />

import { defineConfig, normalizePath } from 'vite'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { resolve } from 'path'
Expand Down Expand Up @@ -51,4 +53,7 @@ export default defineConfig({
drop: ['debugger'],
pure: ['console.log', 'console.warn', 'console.error', 'console.debug', 'console.trace'],
},
test: {
root: '.',
},
})

0 comments on commit f6354bc

Please sign in to comment.