Skip to content

Commit

Permalink
chore: replace Snap with @barelyhuman/node-snapshot and update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Mar 4, 2025
1 parent e39dcdf commit 3dd293d
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 50 deletions.
1 change: 0 additions & 1 deletion adex/.snapshots/0f704ada2712880ee7394b0fc9b10abf/0.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/0f704ada2712880ee7394b0fc9b10abf/1.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/d206b20e870e2750aeb2b376e36d25b3/0.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/d206b20e870e2750aeb2b376e36d25b3/1.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/d206b20e870e2750aeb2b376e36d25b3/2.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/dd4c9d1ee8f7b693c42e503acab1a0c0/0.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/dd4c9d1ee8f7b693c42e503acab1a0c0/1.json

This file was deleted.

1 change: 0 additions & 1 deletion adex/.snapshots/dd4c9d1ee8f7b693c42e503acab1a0c0/2.json

This file was deleted.

3 changes: 2 additions & 1 deletion adex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"test": "glob -c 'node --test --test-reporter=spec' tests/**/*.spec.js"
},
"dependencies": {

"@barelyhuman/tiny-use": "^0.0.2",
"@dumbjs/preland": "^0.0.2",
"bumpp": "^9.4.1",
Expand All @@ -78,7 +79,7 @@
"unifont": "^0.0.2"
},
"devDependencies": {
"@matteo.collina/snap": "^0.3.0",
"@barelyhuman/node-snapshot": "^1.0.2",
"@preact/preset-vite": "^2.8.2",
"@types/node": "^20.14.10",
"adex-adapter-node": "^0.0.17",
Expand Down
47 changes: 47 additions & 0 deletions adex/snapshots/tests/minimal-no-ssr.spec.snap.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
exports["devMode ssr minimal > gives a static response 1"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h1>Hello World</h1></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

exports["devMode ssr minimal > gives a static response 2"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h2>About</h2></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

exports["devMode ssr minimal > blank styles 1"] = `"import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/@id/__x00__virtual:adex:global.css");import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from "/@vite/client"
const __vite__id = "virtual:adex:global.css"
const __vite__css = ""
__vite__updateStyle(__vite__id, __vite__css)
import.meta.hot.accept()
import.meta.hot.prune(() => __vite__removeStyle(__vite__id))"`

40 changes: 40 additions & 0 deletions adex/snapshots/tests/minimal-tailwind.spec.snap.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
exports["devMode ssr minimal with styles > gives a non-static ssr response 1"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h1 class="text-red-500">Hello World</h1></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

exports["devMode ssr minimal with styles > gives a static SSR response 1"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h2>About</h2></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

47 changes: 47 additions & 0 deletions adex/snapshots/tests/minimal.spec.snap.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
exports["devMode ssr minimal > gives a non-static ssr response 1"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h1>Hello World</h1></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

exports["devMode ssr minimal > blank styles 1"] = `"import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/@id/__x00__virtual:adex:global.css");import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from "/@vite/client"
const __vite__id = "virtual:adex:global.css"
const __vite__css = ""
__vite__updateStyle(__vite__id, __vite__css)
import.meta.hot.accept()
import.meta.hot.prune(() => __vite__removeStyle(__vite__id))"`

exports["devMode ssr minimal > gives a static SSR response 1"] = `"
<!doctype html>
<html lang="">
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<div id="app"><h2>About</h2></div>
<script type='module' src="/virtual:adex:client"></script></body>
</html>
"`

17 changes: 10 additions & 7 deletions adex/tests/minimal-no-ssr.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import Snap from '@matteo.collina/snap'
import { snapshot } from '@barelyhuman/node-snapshot'
import { after, before, describe, it } from 'node:test'
import { deepEqual } from 'node:assert/strict'

import { devServerURL, launchDemoDevServer } from './utils.js'

const snap = Snap(import.meta.url)

describe('devMode ssr minimal', async () => {
let devServerProc
before(async () => {
Expand All @@ -19,20 +16,26 @@ describe('devMode ssr minimal', async () => {
const response2 = await fetch(new URL('/', devServerURL)).then(d =>
d.text()
)
deepEqual(response2, await snap(response2))
snapshot(ctx, response2)
})

await it('gives a static response', async ctx => {
const response2 = await fetch(new URL('/about', devServerURL)).then(d =>
d.text()
)
deepEqual(response2, await snap(response2))
snapshot(ctx, response2)
})

await it('blank styles', async ctx => {
const response = await fetch(
new URL('/virtual:adex:global.css', devServerURL)
).then(d => d.text())
deepEqual(response, await snap(response))
snapshot(
ctx,
response.replaceAll(
'\\u0000virtual:adex:global.css',
'virtual:adex:global.css'
)
)
})
})
9 changes: 3 additions & 6 deletions adex/tests/minimal-tailwind.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Snap from '@matteo.collina/snap'
import { after, before, describe, it } from 'node:test'
import assert, { deepEqual } from 'node:assert'

import { devServerURL, launchDemoDevServer } from './utils.js'
const snap = Snap(import.meta.url)
import { snapshot } from '@barelyhuman/node-snapshot'

describe('devMode ssr minimal with styles', async () => {
let devServerProc
Expand All @@ -16,16 +15,14 @@ describe('devMode ssr minimal with styles', async () => {

await it('gives a non-static ssr response', async ctx => {
const response = await fetch(devServerURL).then(d => d.text())
const snapshot = await snap(response)
deepEqual(response, snapshot)
snapshot(ctx, response)
})

await it('gives a static SSR response', async ctx => {
const response2 = await fetch(new URL('/about', devServerURL)).then(d =>
d.text()
)
const snapshot = await snap(response2)
deepEqual(response2, snapshot)
snapshot(ctx, response2)
})

await it('has styles', async ctx => {
Expand Down
17 changes: 10 additions & 7 deletions adex/tests/minimal.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import Snap from '@matteo.collina/snap'
import { after, before, describe, it } from 'node:test'
import { deepEqual } from 'node:assert/strict'

import { devServerURL, launchDemoDevServer } from './utils.js'

const snap = Snap(import.meta.url)
import { snapshot } from '@barelyhuman/node-snapshot'

describe('devMode ssr minimal', async () => {
let devServerProc
Expand All @@ -17,20 +14,26 @@ describe('devMode ssr minimal', async () => {

await it('gives a non-static ssr response', async ctx => {
const response = await fetch(devServerURL).then(d => d.text())
deepEqual(response, await snap(response))
snapshot(ctx, response)
})

await it('gives a static SSR response', async ctx => {
const response2 = await fetch(new URL('/about', devServerURL)).then(d =>
d.text()
)
deepEqual(response2, await snap(response2))
snapshot(ctx, response2)
})

await it('blank styles', async ctx => {
const response = await fetch(
new URL('/virtual:adex:global.css', devServerURL)
).then(d => d.text())
deepEqual(response, await snap(response))
snapshot(
ctx,
response.replaceAll(
'\\u0000virtual:adex:global.css',
'virtual:adex:global.css'
)
)
})
})
Loading

0 comments on commit 3dd293d

Please sign in to comment.