Skip to content

Commit 50718f5

Browse files
committed
test: fix tests
1 parent 73d62d5 commit 50718f5

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ test-results/
3939

4040
# generated files
4141
shared/types/lexicons
42+
43+
**/__screenshots__/**

app/utils/package-name.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import validatePackageName from 'validate-npm-package-name'
2+
import { NPM_REGISTRY } from '#shared/utils/constants'
23

34
/**
45
* Normalize a package name for comparison by removing common variations.

test/nuxt/composables/use-npm-registry.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('usePackageDownloads', () => {
2727

2828
// Check that fetch was called with the correct URL (first argument)
2929
expect(fetchSpy).toHaveBeenCalled()
30-
expect(fetchSpy.mock.calls[0]?.[0]).toBe('https://api.npmjs.org/downloads/point/last-week/vue')
30+
expect(fetchSpy.mock.calls[0]?.[0]).toBe('/downloads/point/last-week/vue')
3131
expect(data.value?.downloads).toBe(1234567)
3232
})
3333

@@ -40,7 +40,7 @@ describe('usePackageDownloads', () => {
4040

4141
// Check that fetch was called with the correct URL (first argument)
4242
expect(fetchSpy).toHaveBeenCalled()
43-
expect(fetchSpy.mock.calls[0]?.[0]).toBe('https://api.npmjs.org/downloads/point/last-month/vue')
43+
expect(fetchSpy.mock.calls[0]?.[0]).toBe('/downloads/point/last-month/vue')
4444
})
4545

4646
it('should encode scoped package names', async () => {
@@ -54,8 +54,6 @@ describe('usePackageDownloads', () => {
5454

5555
// Check that fetch was called with the correct URL (first argument)
5656
expect(fetchSpy).toHaveBeenCalled()
57-
expect(fetchSpy.mock.calls[0]?.[0]).toBe(
58-
'https://api.npmjs.org/downloads/point/last-week/@vue%2Fcore',
59-
)
57+
expect(fetchSpy.mock.calls[0]?.[0]).toBe('/downloads/point/last-week/@vue%2Fcore')
6058
})
6159
})

vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default defineConfig({
3939
},
4040
browser: {
4141
enabled: true,
42+
headless: true,
4243
provider: playwright(),
4344
instances: [{ browser: 'chromium' }],
4445
},

0 commit comments

Comments
 (0)