Skip to content

Commit

Permalink
test: add test in ssr playground
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jan 7, 2025
1 parent 958467a commit 19f7533
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion playground/ssr/__tests__/ssr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ test(`circular dependencies modules doesn't throw`, async () => {
)
})

test(`circular import doesn't throw`, async () => {
test(`circular import doesn't throw (1)`, async () => {
await page.goto(`${url}/circular-import`)

expect(await page.textContent('.circ-import')).toMatchInlineSnapshot(
'"A is: __A__"',
)
})

test(`circular import doesn't throw (2)`, async () => {
await page.goto(`${url}/circular-import2`)

expect(await page.textContent('.circ-import')).toMatchInlineSnapshot(
'"A is: __A__"',
)
})

test(`deadlock doesn't happen for static imports`, async () => {
await page.goto(`${url}/forked-deadlock-static-imports`)

Expand Down
6 changes: 6 additions & 0 deletions playground/ssr/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pathRenderers = {
'/': renderRoot,
'/circular-dep': renderCircularDep,
'/circular-import': renderCircularImport,
'/circular-import2': renderCircularImport2,
'/forked-deadlock-static-imports': renderForkedDeadlockStaticImports,
'/forked-deadlock-dynamic-imports': renderForkedDeadlockDynamicImports,
}
Expand Down Expand Up @@ -41,6 +42,11 @@ async function renderCircularImport(rootDir) {
return `<div class="circ-import">${escapeHtml(logA())}</div>`
}

async function renderCircularImport2(rootDir) {
const { logA } = await import('./circular-import2/index.js')
return `<div class="circ-import">${escapeHtml(logA())}</div>`
}

async function renderForkedDeadlockStaticImports(rootDir) {
const { commonModuleExport } = await import('./forked-deadlock/common-module')
commonModuleExport()
Expand Down
5 changes: 5 additions & 0 deletions playground/ssr/src/circular-import2/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getB } from './b'

export const A = '__A__'

export const B = getB()
5 changes: 5 additions & 0 deletions playground/ssr/src/circular-import2/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { A } from './a'

export function getB() {
return '__B__'
}
5 changes: 5 additions & 0 deletions playground/ssr/src/circular-import2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { A } from './b'

export function logA() {
return `A is: ${A}`
}

0 comments on commit 19f7533

Please sign in to comment.