Skip to content

Commit 1a55a49

Browse files
committed
add import.meta.url test case
1 parent 42fa908 commit 1a55a49

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const text = import.meta.url
2+
3+
export default function Page() {
4+
return <p>{text}</p>
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
const text = import.meta.url
4+
5+
export default function Page() {
6+
return <p>{text}</p>
7+
}

test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ describe('non-root-project-monorepo', () => {
4848
})
4949
})
5050

51+
describe('import.meta.url', () => {
52+
it('should work during RSC', async () => {
53+
const $ = await next.render$('/import-meta-url-rsc')
54+
expect($('p').text()).toMatch(
55+
/^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-rsc\/page.tsx$/
56+
)
57+
})
58+
59+
it('should work during SSR', async () => {
60+
const $ = await next.render$('/import-meta-url-ssr')
61+
expect($('p').text()).toMatch(
62+
/^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-ssr\/page.tsx$/
63+
)
64+
})
65+
66+
it('should work on client-side', async () => {
67+
const browser = await next.browser('/import-meta-url-ssr')
68+
await assertNoRedbox(browser)
69+
if (isTurbopack) {
70+
// Turbopack intentionally doesn't expose the full path to the browser bundles
71+
expect(await browser.elementByCss('p').text()).toBe(
72+
'file:///ROOT/apps/web/app/import-meta-url-ssr/page.tsx'
73+
)
74+
} else {
75+
expect(await browser.elementByCss('p').text()).toMatch(
76+
/^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-ssr\/page.tsx$/
77+
)
78+
}
79+
await browser.close()
80+
})
81+
})
82+
5183
if (isNextDev) {
5284
describe('source-maps', () => {
5385
function normalizeStackTrace(stack: string): string {

0 commit comments

Comments
 (0)