mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
We forked test assertions in places in the early days of merging Turbopack. Now that we more closely align, a bunch of these had the exact same assertions. Fold them into one.
32 lines
908 B
TypeScript
32 lines
908 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('import-meta', () => {
|
|
const { next, isTurbopack } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
describe('import.meta.url', () => {
|
|
it('should work on the server', async () => {
|
|
const $ = await next.render$('/')
|
|
const testData = $('#test-data').text()
|
|
const data = JSON.parse(testData)
|
|
|
|
expect(data.url).toStartWith('file:///')
|
|
expect(data.url).toEndWith('/pages/index.tsx')
|
|
})
|
|
|
|
it('should work in browser', async () => {
|
|
const browser = await next.browser('/')
|
|
const testData = await browser.elementByCss('#test-data').text()
|
|
const data = JSON.parse(testData)
|
|
|
|
if (isTurbopack) {
|
|
expect(data.url).toBe('file:///ROOT/pages/index.tsx')
|
|
} else {
|
|
expect(data.url).toStartWith('file:///')
|
|
expect(data.url).toEndWith('/pages/index.tsx')
|
|
}
|
|
})
|
|
})
|
|
})
|