Skip to content

Commit

Permalink
test: simplify playground/json/__tests__/ssr (#18701)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Nov 18, 2024
1 parent 818cf3e commit f731ca2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 177 deletions.
3 changes: 3 additions & 0 deletions packages/vite/src/node/ssr/__tests__/fixtures/json/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "this is json"
}
25 changes: 25 additions & 0 deletions packages/vite/src/node/ssr/__tests__/ssrLoadModule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import fs from 'node:fs'
import { stripVTControlCharacters } from 'node:util'
import { expect, test } from 'vitest'
import { createServer } from '../../server'
Expand Down Expand Up @@ -212,3 +213,27 @@ test('parse error', async () => {
expect.unreachable()
}
})

test('json', async () => {
const server = await createDevServer()
const mod = await server.ssrLoadModule('/fixtures/json/test.json')
expect(mod).toMatchInlineSnapshot(`
{
"default": {
"hello": "this is json",
},
"hello": "this is json",
}
`)

const source = fs.readFileSync(
path.join(root, 'fixtures/json/test.json'),
'utf-8',
)
const json = await server.ssrTransform(
`export default ${source}`,
null,
'/test.json',
)
expect(json?.code.length).toMatchInlineSnapshot(`61`)
})
23 changes: 0 additions & 23 deletions playground/json/__tests__/ssr/json-ssr.spec.ts

This file was deleted.

35 changes: 0 additions & 35 deletions playground/json/__tests__/ssr/serve.ts

This file was deleted.

23 changes: 0 additions & 23 deletions playground/json/index.ssr.html

This file was deleted.

5 changes: 1 addition & 4 deletions playground/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"dev": "vite",
"build": "vite build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview",
"dev:ssr": "node server",
"serve:ssr": "NODE_ENV=production node server",
"debug:ssr": "node --inspect-brk server"
"preview": "vite preview"
},
"devDependencies": {
"@vitejs/test-json-module": "file:./json-module",
Expand Down
92 changes: 0 additions & 92 deletions playground/json/server.js

This file was deleted.

0 comments on commit f731ca2

Please sign in to comment.