Unverified Commit 19013a5e authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure next.url is used instead of next.appPort (#44163)

`appPort` shouldn't be used unless absolutely necessary as `next.url` is
more specific and allows more control.

x-ref:
https://github.com/vercel/next.js/actions/runs/3734223762/jobs/6336069606
parent 3dd9af78
...@@ -20,7 +20,7 @@ export async function sandbox( ...@@ -20,7 +20,7 @@ export async function sandbox(
} }
} }
await next.start() await next.start()
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
return { return {
browser, browser,
session: { session: {
......
...@@ -29,7 +29,7 @@ export async function sandbox( ...@@ -29,7 +29,7 @@ export async function sandbox(
} }
} }
await next.start() await next.start()
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
return { return {
session: { session: {
async write(filename, content) { async write(filename, content) {
......
...@@ -36,7 +36,7 @@ describe('basic HMR', () => { ...@@ -36,7 +36,7 @@ describe('basic HMR', () => {
const newContactPagePath = join('pages', 'hmr', '_contact.js') const newContactPagePath = join('pages', 'hmr', '_contact.js')
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/contact') browser = await webdriver(next.url, '/docs/hmr/contact')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('This is the contact page.') expect(text).toBe('This is the contact page.')
...@@ -71,7 +71,7 @@ describe('basic HMR', () => { ...@@ -71,7 +71,7 @@ describe('basic HMR', () => {
it('should detect the changes and display it', async () => { it('should detect the changes and display it', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about') browser = await webdriver(next.url, '/docs/hmr/about')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('This is the about page.') expect(text).toBe('This is the about page.')
...@@ -106,7 +106,7 @@ describe('basic HMR', () => { ...@@ -106,7 +106,7 @@ describe('basic HMR', () => {
it('should not reload unrelated pages', async () => { it('should not reload unrelated pages', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/counter') browser = await webdriver(next.url, '/docs/hmr/counter')
const text = await browser const text = await browser
.elementByCss('button') .elementByCss('button')
.click() .click()
...@@ -146,7 +146,7 @@ describe('basic HMR', () => { ...@@ -146,7 +146,7 @@ describe('basic HMR', () => {
it('should update styles correctly', async () => { it('should update styles correctly', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/style') browser = await webdriver(next.url, '/docs/hmr/style')
const pTag = await browser.elementByCss('.hmr-style-page p') const pTag = await browser.elementByCss('.hmr-style-page p')
const initialFontSize = await pTag.getComputedCss('font-size') const initialFontSize = await pTag.getComputedCss('font-size')
...@@ -186,7 +186,7 @@ describe('basic HMR', () => { ...@@ -186,7 +186,7 @@ describe('basic HMR', () => {
const originalContent = await next.readFile(pagePath) const originalContent = await next.readFile(pagePath)
try { try {
browser = await webdriver( browser = await webdriver(
next.appPort, next.url,
'/docs/hmr/style-stateful-component' '/docs/hmr/style-stateful-component'
) )
const pTag = await browser.elementByCss('.hmr-style-page p') const pTag = await browser.elementByCss('.hmr-style-page p')
...@@ -220,7 +220,7 @@ describe('basic HMR', () => { ...@@ -220,7 +220,7 @@ describe('basic HMR', () => {
const originalContent = await next.readFile(pagePath) const originalContent = await next.readFile(pagePath)
try { try {
browser = await webdriver( browser = await webdriver(
next.appPort, next.url,
'/docs/hmr/style-dynamic-component' '/docs/hmr/style-dynamic-component'
) )
const div = await browser.elementByCss('#dynamic-component') const div = await browser.elementByCss('#dynamic-component')
...@@ -230,7 +230,7 @@ describe('basic HMR', () => { ...@@ -230,7 +230,7 @@ describe('basic HMR', () => {
expect(initialFontSize).toBe('100px') expect(initialFontSize).toBe('100px')
const initialHtml = await renderViaHTTP( const initialHtml = await renderViaHTTP(
next.appPort, next.url,
'/docs/hmr/style-dynamic-component' '/docs/hmr/style-dynamic-component'
) )
expect(initialHtml.includes('100px')).toBeTruthy() expect(initialHtml.includes('100px')).toBeTruthy()
...@@ -250,7 +250,7 @@ describe('basic HMR', () => { ...@@ -250,7 +250,7 @@ describe('basic HMR', () => {
await waitFor(5000) await waitFor(5000)
secondBrowser = await webdriver( secondBrowser = await webdriver(
next.appPort, next.url,
'/docs/hmr/style-dynamic-component' '/docs/hmr/style-dynamic-component'
) )
// Check whether the this page has reloaded or not. // Check whether the this page has reloaded or not.
...@@ -268,7 +268,7 @@ describe('basic HMR', () => { ...@@ -268,7 +268,7 @@ describe('basic HMR', () => {
expect(browserHtml.includes('font-size:100px')).toBe(false) expect(browserHtml.includes('font-size:100px')).toBe(false)
const editedHtml = await renderViaHTTP( const editedHtml = await renderViaHTTP(
next.appPort, next.url,
'/docs/hmr/style-dynamic-component' '/docs/hmr/style-dynamic-component'
) )
expect(editedHtml.includes('200px')).toBeTruthy() expect(editedHtml.includes('200px')).toBeTruthy()
...@@ -300,7 +300,7 @@ describe('basic HMR', () => { ...@@ -300,7 +300,7 @@ describe('basic HMR', () => {
const newPage = join('pages', 'hmr', 'new-page.js') const newPage = join('pages', 'hmr', 'new-page.js')
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/new-page') browser = await webdriver(next.url, '/docs/hmr/new-page')
expect(await browser.elementByCss('body').text()).toMatch( expect(await browser.elementByCss('body').text()).toMatch(
/This page could not be found/ /This page could not be found/
...@@ -335,7 +335,7 @@ describe('basic HMR', () => { ...@@ -335,7 +335,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about2.js') const aboutPage = join('pages', 'hmr', 'about2.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about2') browser = await webdriver(next.url, '/docs/hmr/about2')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div')) await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
...@@ -368,14 +368,14 @@ describe('basic HMR', () => { ...@@ -368,14 +368,14 @@ describe('basic HMR', () => {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
let browser let browser
try { try {
await renderViaHTTP(next.appPort, '/docs/hmr/about2') await renderViaHTTP(next.url, '/docs/hmr/about2')
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div')) await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
// Ensure dev server has time to break: // Ensure dev server has time to break:
await new Promise((resolve) => setTimeout(resolve, 2000)) await new Promise((resolve) => setTimeout(resolve, 2000))
browser = await webdriver(next.appPort, '/docs/hmr/contact') browser = await webdriver(next.url, '/docs/hmr/contact')
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxSource(browser)).toMatch(/Unexpected eof/) expect(await getRedboxSource(browser)).toMatch(/Unexpected eof/)
...@@ -408,7 +408,7 @@ describe('basic HMR', () => { ...@@ -408,7 +408,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about3.js') const aboutPage = join('pages', 'hmr', 'about3.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about3') browser = await webdriver(next.url, '/docs/hmr/about3')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -435,7 +435,7 @@ describe('basic HMR', () => { ...@@ -435,7 +435,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about4.js') const aboutPage = join('pages', 'hmr', 'about4.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about4') browser = await webdriver(next.url, '/docs/hmr/about4')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -474,7 +474,7 @@ describe('basic HMR', () => { ...@@ -474,7 +474,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about5.js') const aboutPage = join('pages', 'hmr', 'about5.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about5') browser = await webdriver(next.url, '/docs/hmr/about5')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -521,7 +521,7 @@ describe('basic HMR', () => { ...@@ -521,7 +521,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about6.js') const aboutPage = join('pages', 'hmr', 'about6.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about6') browser = await webdriver(next.url, '/docs/hmr/about6')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -565,7 +565,7 @@ describe('basic HMR', () => { ...@@ -565,7 +565,7 @@ describe('basic HMR', () => {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/about7') browser = await webdriver(next.url, '/docs/hmr/about7')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -613,7 +613,7 @@ describe('basic HMR', () => { ...@@ -613,7 +613,7 @@ describe('basic HMR', () => {
const erroredPage = join('pages', 'hmr', 'error-in-gip.js') const erroredPage = join('pages', 'hmr', 'error-in-gip.js')
const errorContent = await next.readFile(erroredPage) const errorContent = await next.readFile(erroredPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr') browser = await webdriver(next.url, '/docs/hmr')
await browser.elementByCss('#error-in-gip-link').click() await browser.elementByCss('#error-in-gip-link').click()
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
...@@ -658,7 +658,7 @@ describe('basic HMR', () => { ...@@ -658,7 +658,7 @@ describe('basic HMR', () => {
const erroredPage = join('pages', 'hmr', 'error-in-gip.js') const erroredPage = join('pages', 'hmr', 'error-in-gip.js')
const errorContent = await next.readFile(erroredPage) const errorContent = await next.readFile(erroredPage)
try { try {
browser = await webdriver(next.appPort, '/docs/hmr/error-in-gip') browser = await webdriver(next.url, '/docs/hmr/error-in-gip')
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(` expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(`
......
...@@ -22,17 +22,17 @@ describe('misc basic dev tests', () => { ...@@ -22,17 +22,17 @@ describe('misc basic dev tests', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
it('should set process.env.NODE_ENV in development', async () => { it('should set process.env.NODE_ENV in development', async () => {
const browser = await webdriver(next.appPort, '/docs/process-env') const browser = await webdriver(next.url, '/docs/process-env')
const nodeEnv = await browser.elementByCss('#node-env').text() const nodeEnv = await browser.elementByCss('#node-env').text()
expect(nodeEnv).toBe('development') expect(nodeEnv).toBe('development')
await browser.close() await browser.close()
}) })
it('should allow access to public files', async () => { it('should allow access to public files', async () => {
const data = await renderViaHTTP(next.appPort, '/docs/data/data.txt') const data = await renderViaHTTP(next.url, '/docs/data/data.txt')
expect(data).toBe('data') expect(data).toBe('data')
const legacy = await renderViaHTTP(next.appPort, '/docs/static/legacy.txt') const legacy = await renderViaHTTP(next.url, '/docs/static/legacy.txt')
expect(legacy).toMatch(`new static folder`) expect(legacy).toMatch(`new static folder`)
}) })
...@@ -43,7 +43,7 @@ describe('misc basic dev tests', () => { ...@@ -43,7 +43,7 @@ describe('misc basic dev tests', () => {
`/docs/_next/static/../routes-manifest.json`, `/docs/_next/static/../routes-manifest.json`,
] ]
for (const path of pathsToCheck) { for (const path of pathsToCheck) {
const res = await fetchViaHTTP(next.appPort, path) const res = await fetchViaHTTP(next.url, path)
const text = await res.text() const text = await res.text()
try { try {
expect(res.status).toBe(404) expect(res.status).toBe(404)
...@@ -56,7 +56,7 @@ describe('misc basic dev tests', () => { ...@@ -56,7 +56,7 @@ describe('misc basic dev tests', () => {
it('should handle encoded / value for trailing slash correctly', async () => { it('should handle encoded / value for trailing slash correctly', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(
next.appPort, next.url,
'/docs/%2fexample.com/', '/docs/%2fexample.com/',
undefined, undefined,
{ redirect: 'manual' } { redirect: 'manual' }
...@@ -77,7 +77,7 @@ describe('misc basic dev tests', () => { ...@@ -77,7 +77,7 @@ describe('misc basic dev tests', () => {
let foundLog = false let foundLog = false
let browser let browser
try { try {
browser = await webdriver(next.appPort, path) browser = await webdriver(next.url, path)
const browserLogs = await browser.log('browser') const browserLogs = await browser.log('browser')
browserLogs.forEach((log) => { browserLogs.forEach((log) => {
......
...@@ -22,7 +22,7 @@ describe('basic next/dynamic usage', () => { ...@@ -22,7 +22,7 @@ describe('basic next/dynamic usage', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
async function get$(path, query?: any) { async function get$(path, query?: any) {
const html = await renderViaHTTP(next.appPort, path, query) const html = await renderViaHTTP(next.url, path, query)
return cheerio.load(html) return cheerio.load(html)
} }
...@@ -49,7 +49,7 @@ describe('basic next/dynamic usage', () => { ...@@ -49,7 +49,7 @@ describe('basic next/dynamic usage', () => {
it('should render even there are no physical chunk exists', async () => { it('should render even there are no physical chunk exists', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/no-chunk') browser = await webdriver(next.url, '/docs/dynamic/no-chunk')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Welcome, normal/ /Welcome, normal/
...@@ -68,7 +68,7 @@ describe('basic next/dynamic usage', () => { ...@@ -68,7 +68,7 @@ describe('basic next/dynamic usage', () => {
it('should hydrate nested chunks', async () => { it('should hydrate nested chunks', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/nested') browser = await webdriver(next.url, '/docs/dynamic/nested')
await check(() => browser.elementByCss('body').text(), /Nested 1/) await check(() => browser.elementByCss('body').text(), /Nested 1/)
await check(() => browser.elementByCss('body').text(), /Nested 2/) await check(() => browser.elementByCss('body').text(), /Nested 2/)
await check( await check(
...@@ -95,7 +95,7 @@ describe('basic next/dynamic usage', () => { ...@@ -95,7 +95,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component Head content', async () => { it('should render the component Head content', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/head') browser = await webdriver(next.url, '/docs/dynamic/head')
await check(() => browser.elementByCss('body').text(), /test/) await check(() => browser.elementByCss('body').text(), /test/)
const backgroundColor = await browser const backgroundColor = await browser
.elementByCss('.dynamic-style') .elementByCss('.dynamic-style')
...@@ -122,7 +122,7 @@ describe('basic next/dynamic usage', () => { ...@@ -122,7 +122,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/no-ssr') browser = await webdriver(next.url, '/docs/dynamic/no-ssr')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Hello World 1/ /Hello World 1/
...@@ -154,7 +154,7 @@ describe('basic next/dynamic usage', () => { ...@@ -154,7 +154,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/ssr-true') browser = await webdriver(next.url, '/docs/dynamic/ssr-true')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Hello World 1/ /Hello World 1/
...@@ -177,7 +177,7 @@ describe('basic next/dynamic usage', () => { ...@@ -177,7 +177,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/docs/dynamic/chunkfilename') browser = await webdriver(next.url, '/docs/dynamic/chunkfilename')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/test chunkfilename/ /test chunkfilename/
...@@ -200,7 +200,7 @@ describe('basic next/dynamic usage', () => { ...@@ -200,7 +200,7 @@ describe('basic next/dynamic usage', () => {
let browser let browser
try { try {
browser = await webdriver( browser = await webdriver(
next.appPort, next.url,
'/docs/dynamic/no-ssr-custom-loading' '/docs/dynamic/no-ssr-custom-loading'
) )
await check( await check(
...@@ -226,10 +226,7 @@ describe('basic next/dynamic usage', () => { ...@@ -226,10 +226,7 @@ describe('basic next/dynamic usage', () => {
it('should only load the rendered module in the browser', async () => { it('should only load the rendered module in the browser', async () => {
let browser let browser
try { try {
browser = await webdriver( browser = await webdriver(next.url, '/docs/dynamic/multiple-modules')
next.appPort,
'/docs/dynamic/multiple-modules'
)
const html = await browser.eval('document.documentElement.innerHTML') const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch(/hello1\.js/) expect(html).toMatch(/hello1\.js/)
expect(html).not.toMatch(/hello2\.js/) expect(html).not.toMatch(/hello2\.js/)
......
...@@ -30,7 +30,7 @@ describe('useDefineForClassFields SWC option', () => { ...@@ -30,7 +30,7 @@ describe('useDefineForClassFields SWC option', () => {
it('tsx should compile with useDefineForClassFields enabled', async () => { it('tsx should compile with useDefineForClassFields enabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
await browser.elementByCss('#action').click() await browser.elementByCss('#action').click()
await check( await check(
() => browser.elementByCss('#name').text(), () => browser.elementByCss('#name').text(),
...@@ -46,7 +46,7 @@ describe('useDefineForClassFields SWC option', () => { ...@@ -46,7 +46,7 @@ describe('useDefineForClassFields SWC option', () => {
it("Initializes resident to undefined after the call to 'super()' when with useDefineForClassFields enabled", async () => { it("Initializes resident to undefined after the call to 'super()' when with useDefineForClassFields enabled", async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/animal') browser = await webdriver(next.url, '/animal')
expect(await browser.elementByCss('#dog').text()).toBe('') expect(await browser.elementByCss('#dog').text()).toBe('')
expect(await browser.elementByCss('#dogDecl').text()).toBe('dog') expect(await browser.elementByCss('#dogDecl').text()).toBe('dog')
} finally { } finally {
...@@ -76,7 +76,7 @@ describe('useDefineForClassFields SWC option', () => { ...@@ -76,7 +76,7 @@ describe('useDefineForClassFields SWC option', () => {
it('set accessors from base classes won’t get triggered with useDefineForClassFields enabled', async () => { it('set accessors from base classes won’t get triggered with useDefineForClassFields enabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/derived') browser = await webdriver(next.url, '/derived')
await matchLogs$(browser).then(([data_foundLog, name_foundLog]) => { await matchLogs$(browser).then(([data_foundLog, name_foundLog]) => {
expect(data_foundLog).toBe(true) expect(data_foundLog).toBe(true)
expect(name_foundLog).toBe(false) expect(name_foundLog).toBe(false)
......
...@@ -29,7 +29,7 @@ describe('emotion SWC option', () => { ...@@ -29,7 +29,7 @@ describe('emotion SWC option', () => {
it('should have styling from the css prop', async () => { it('should have styling from the css prop', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
const color = await browser const color = await browser
.elementByCss('#test-element') .elementByCss('#test-element')
.getComputedCss('background-color') .getComputedCss('background-color')
......
...@@ -78,7 +78,7 @@ describe('basic HMR', () => { ...@@ -78,7 +78,7 @@ describe('basic HMR', () => {
let browser let browser
try { try {
const start = next.cliOutput.length const start = next.cliOutput.length
browser = await webdriver(next.appPort, '/hmr/contact') browser = await webdriver(next.url, '/hmr/contact')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('This is the contact page.') expect(text).toBe('This is the contact page.')
...@@ -121,7 +121,7 @@ describe('basic HMR', () => { ...@@ -121,7 +121,7 @@ describe('basic HMR', () => {
it('should detect the changes and display it', async () => { it('should detect the changes and display it', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/hmr/about') browser = await webdriver(next.url, '/hmr/about')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('This is the about page.') expect(text).toBe('This is the about page.')
...@@ -156,7 +156,7 @@ describe('basic HMR', () => { ...@@ -156,7 +156,7 @@ describe('basic HMR', () => {
it('should not reload unrelated pages', async () => { it('should not reload unrelated pages', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/hmr/counter') browser = await webdriver(next.url, '/hmr/counter')
const text = await browser const text = await browser
.elementByCss('button') .elementByCss('button')
.click() .click()
...@@ -196,7 +196,7 @@ describe('basic HMR', () => { ...@@ -196,7 +196,7 @@ describe('basic HMR', () => {
it('should update styles correctly', async () => { it('should update styles correctly', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/hmr/style') browser = await webdriver(next.url, '/hmr/style')
const pTag = await browser.elementByCss('.hmr-style-page p') const pTag = await browser.elementByCss('.hmr-style-page p')
const initialFontSize = await pTag.getComputedCss('font-size') const initialFontSize = await pTag.getComputedCss('font-size')
...@@ -235,10 +235,7 @@ describe('basic HMR', () => { ...@@ -235,10 +235,7 @@ describe('basic HMR', () => {
const pagePath = join('pages', 'hmr', 'style-stateful-component.js') const pagePath = join('pages', 'hmr', 'style-stateful-component.js')
const originalContent = await next.readFile(pagePath) const originalContent = await next.readFile(pagePath)
try { try {
browser = await webdriver( browser = await webdriver(next.url, '/hmr/style-stateful-component')
next.appPort,
'/hmr/style-stateful-component'
)
const pTag = await browser.elementByCss('.hmr-style-page p') const pTag = await browser.elementByCss('.hmr-style-page p')
const initialFontSize = await pTag.getComputedCss('font-size') const initialFontSize = await pTag.getComputedCss('font-size')
...@@ -269,10 +266,7 @@ describe('basic HMR', () => { ...@@ -269,10 +266,7 @@ describe('basic HMR', () => {
const pagePath = join('components', 'hmr', 'dynamic.js') const pagePath = join('components', 'hmr', 'dynamic.js')
const originalContent = await next.readFile(pagePath) const originalContent = await next.readFile(pagePath)
try { try {
browser = await webdriver( browser = await webdriver(next.url, '/hmr/style-dynamic-component')
next.appPort,
'/hmr/style-dynamic-component'
)
const div = await browser.elementByCss('#dynamic-component') const div = await browser.elementByCss('#dynamic-component')
const initialClientClassName = await div.getAttribute('class') const initialClientClassName = await div.getAttribute('class')
const initialFontSize = await div.getComputedCss('font-size') const initialFontSize = await div.getComputedCss('font-size')
...@@ -280,7 +274,7 @@ describe('basic HMR', () => { ...@@ -280,7 +274,7 @@ describe('basic HMR', () => {
expect(initialFontSize).toBe('100px') expect(initialFontSize).toBe('100px')
const initialHtml = await renderViaHTTP( const initialHtml = await renderViaHTTP(
next.appPort, next.url,
'/hmr/style-dynamic-component' '/hmr/style-dynamic-component'
) )
expect(initialHtml.includes('100px')).toBeTruthy() expect(initialHtml.includes('100px')).toBeTruthy()
...@@ -300,7 +294,7 @@ describe('basic HMR', () => { ...@@ -300,7 +294,7 @@ describe('basic HMR', () => {
await waitFor(5000) await waitFor(5000)
secondBrowser = await webdriver( secondBrowser = await webdriver(
next.appPort, next.url,
'/hmr/style-dynamic-component' '/hmr/style-dynamic-component'
) )
// Check whether the this page has reloaded or not. // Check whether the this page has reloaded or not.
...@@ -318,7 +312,7 @@ describe('basic HMR', () => { ...@@ -318,7 +312,7 @@ describe('basic HMR', () => {
expect(browserHtml.includes('font-size:100px')).toBe(false) expect(browserHtml.includes('font-size:100px')).toBe(false)
const editedHtml = await renderViaHTTP( const editedHtml = await renderViaHTTP(
next.appPort, next.url,
'/hmr/style-dynamic-component' '/hmr/style-dynamic-component'
) )
expect(editedHtml.includes('200px')).toBeTruthy() expect(editedHtml.includes('200px')).toBeTruthy()
...@@ -351,7 +345,7 @@ describe('basic HMR', () => { ...@@ -351,7 +345,7 @@ describe('basic HMR', () => {
try { try {
const start = next.cliOutput.length const start = next.cliOutput.length
browser = await webdriver(next.appPort, '/hmr/new-page') browser = await webdriver(next.url, '/hmr/new-page')
expect(await browser.elementByCss('body').text()).toMatch( expect(await browser.elementByCss('body').text()).toMatch(
/This page could not be found/ /This page could not be found/
...@@ -394,7 +388,7 @@ describe('basic HMR', () => { ...@@ -394,7 +388,7 @@ describe('basic HMR', () => {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
const start = next.cliOutput.length const start = next.cliOutput.length
browser = await webdriver(next.appPort, '/hmr/about2') browser = await webdriver(next.url, '/hmr/about2')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div')) await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
...@@ -433,14 +427,14 @@ describe('basic HMR', () => { ...@@ -433,14 +427,14 @@ describe('basic HMR', () => {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
let browser let browser
try { try {
await renderViaHTTP(next.appPort, '/hmr/about2') await renderViaHTTP(next.url, '/hmr/about2')
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div')) await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
// Ensure dev server has time to break: // Ensure dev server has time to break:
await new Promise((resolve) => setTimeout(resolve, 2000)) await new Promise((resolve) => setTimeout(resolve, 2000))
browser = await webdriver(next.appPort, '/hmr/contact') browser = await webdriver(next.url, '/hmr/contact')
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxSource(browser)).toMatch(/Unexpected eof/) expect(await getRedboxSource(browser)).toMatch(/Unexpected eof/)
...@@ -473,7 +467,7 @@ describe('basic HMR', () => { ...@@ -473,7 +467,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about3.js') const aboutPage = join('pages', 'hmr', 'about3.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/about3') browser = await webdriver(next.url, '/hmr/about3')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -500,7 +494,7 @@ describe('basic HMR', () => { ...@@ -500,7 +494,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about4.js') const aboutPage = join('pages', 'hmr', 'about4.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/about4') browser = await webdriver(next.url, '/hmr/about4')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -539,7 +533,7 @@ describe('basic HMR', () => { ...@@ -539,7 +533,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about5.js') const aboutPage = join('pages', 'hmr', 'about5.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/about5') browser = await webdriver(next.url, '/hmr/about5')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -586,7 +580,7 @@ describe('basic HMR', () => { ...@@ -586,7 +580,7 @@ describe('basic HMR', () => {
const aboutPage = join('pages', 'hmr', 'about6.js') const aboutPage = join('pages', 'hmr', 'about6.js')
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/about6') browser = await webdriver(next.url, '/hmr/about6')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -630,7 +624,7 @@ describe('basic HMR', () => { ...@@ -630,7 +624,7 @@ describe('basic HMR', () => {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/about7') browser = await webdriver(next.url, '/hmr/about7')
await check(() => getBrowserBodyText(browser), /This is the about page/) await check(() => getBrowserBodyText(browser), /This is the about page/)
await next.patchFile( await next.patchFile(
...@@ -678,7 +672,7 @@ describe('basic HMR', () => { ...@@ -678,7 +672,7 @@ describe('basic HMR', () => {
const erroredPage = join('pages', 'hmr', 'error-in-gip.js') const erroredPage = join('pages', 'hmr', 'error-in-gip.js')
const errorContent = await next.readFile(erroredPage) const errorContent = await next.readFile(erroredPage)
try { try {
browser = await webdriver(next.appPort, '/hmr') browser = await webdriver(next.url, '/hmr')
await browser.elementByCss('#error-in-gip-link').click() await browser.elementByCss('#error-in-gip-link').click()
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
...@@ -723,7 +717,7 @@ describe('basic HMR', () => { ...@@ -723,7 +717,7 @@ describe('basic HMR', () => {
const erroredPage = join('pages', 'hmr', 'error-in-gip.js') const erroredPage = join('pages', 'hmr', 'error-in-gip.js')
const errorContent = await next.readFile(erroredPage) const errorContent = await next.readFile(erroredPage)
try { try {
browser = await webdriver(next.appPort, '/hmr/error-in-gip') browser = await webdriver(next.url, '/hmr/error-in-gip')
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(` expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(`
...@@ -770,10 +764,7 @@ describe('basic HMR', () => { ...@@ -770,10 +764,7 @@ describe('basic HMR', () => {
describe('Full reload', () => { describe('Full reload', () => {
it('should warn about full reload in cli output - anonymous page function', async () => { it('should warn about full reload in cli output - anonymous page function', async () => {
const start = next.cliOutput.length const start = next.cliOutput.length
const browser = await webdriver( const browser = await webdriver(next.url, `/hmr/anonymous-page-function`)
next.appPort,
`/hmr/anonymous-page-function`
)
const cliWarning = const cliWarning =
'Fast Refresh had to perform a full reload when ./pages/hmr/anonymous-page-function.js changed. Read more: https://nextjs.org/docs/messages/fast-refresh-reload' 'Fast Refresh had to perform a full reload when ./pages/hmr/anonymous-page-function.js changed. Read more: https://nextjs.org/docs/messages/fast-refresh-reload'
...@@ -812,7 +803,7 @@ describe('basic HMR', () => { ...@@ -812,7 +803,7 @@ describe('basic HMR', () => {
it('should warn about full reload in cli output - runtime-error', async () => { it('should warn about full reload in cli output - runtime-error', async () => {
const start = next.cliOutput.length const start = next.cliOutput.length
const browser = await webdriver(next.appPort, `/hmr/runtime-error`) const browser = await webdriver(next.url, `/hmr/runtime-error`)
const cliWarning = const cliWarning =
'Fast Refresh had to perform a full reload due to a runtime error.' 'Fast Refresh had to perform a full reload due to a runtime error.'
......
...@@ -26,7 +26,7 @@ describe('Legacy decorators SWC option', () => { ...@@ -26,7 +26,7 @@ describe('Legacy decorators SWC option', () => {
it('should compile with legacy decorators enabled', async () => { it('should compile with legacy decorators enabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
const text = await browser.elementByCss('#count').text() const text = await browser.elementByCss('#count').text()
expect(text).toBe('Current number: 0') expect(text).toBe('Current number: 0')
await browser.elementByCss('#increase').click() await browser.elementByCss('#increase').click()
......
...@@ -19,17 +19,17 @@ describe('misc basic dev tests', () => { ...@@ -19,17 +19,17 @@ describe('misc basic dev tests', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
it('should set process.env.NODE_ENV in development', async () => { it('should set process.env.NODE_ENV in development', async () => {
const browser = await webdriver(next.appPort, '/process-env') const browser = await webdriver(next.url, '/process-env')
const nodeEnv = await browser.elementByCss('#node-env').text() const nodeEnv = await browser.elementByCss('#node-env').text()
expect(nodeEnv).toBe('development') expect(nodeEnv).toBe('development')
await browser.close() await browser.close()
}) })
it('should allow access to public files', async () => { it('should allow access to public files', async () => {
const data = await renderViaHTTP(next.appPort, '/data/data.txt') const data = await renderViaHTTP(next.url, '/data/data.txt')
expect(data).toBe('data') expect(data).toBe('data')
const legacy = await renderViaHTTP(next.appPort, '/static/legacy.txt') const legacy = await renderViaHTTP(next.url, '/static/legacy.txt')
expect(legacy).toMatch(`new static folder`) expect(legacy).toMatch(`new static folder`)
}) })
...@@ -40,7 +40,7 @@ describe('misc basic dev tests', () => { ...@@ -40,7 +40,7 @@ describe('misc basic dev tests', () => {
`/_next/static/../routes-manifest.json`, `/_next/static/../routes-manifest.json`,
] ]
for (const path of pathsToCheck) { for (const path of pathsToCheck) {
const res = await fetchViaHTTP(next.appPort, path) const res = await fetchViaHTTP(next.url, path)
const text = await res.text() const text = await res.text()
try { try {
expect(res.status).toBe(404) expect(res.status).toBe(404)
...@@ -52,12 +52,9 @@ describe('misc basic dev tests', () => { ...@@ -52,12 +52,9 @@ describe('misc basic dev tests', () => {
}) })
it('should handle encoded / value for trailing slash correctly', async () => { it('should handle encoded / value for trailing slash correctly', async () => {
const res = await fetchViaHTTP( const res = await fetchViaHTTP(next.url, '/%2fexample.com/', undefined, {
next.appPort, redirect: 'manual',
'/%2fexample.com/', })
undefined,
{ redirect: 'manual' }
)
const { pathname, hostname } = url.parse( const { pathname, hostname } = url.parse(
res.headers.get('location') || '' res.headers.get('location') || ''
...@@ -74,7 +71,7 @@ describe('misc basic dev tests', () => { ...@@ -74,7 +71,7 @@ describe('misc basic dev tests', () => {
let foundLog = false let foundLog = false
let browser let browser
try { try {
browser = await webdriver(next.appPort, path) browser = await webdriver(next.url, path)
const browserLogs = await browser.log('browser') const browserLogs = await browser.log('browser')
browserLogs.forEach((log) => { browserLogs.forEach((log) => {
......
...@@ -19,7 +19,7 @@ describe('basic next/dynamic usage', () => { ...@@ -19,7 +19,7 @@ describe('basic next/dynamic usage', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
async function get$(path, query?: any) { async function get$(path, query?: any) {
const html = await renderViaHTTP(next.appPort, path, query) const html = await renderViaHTTP(next.url, path, query)
return cheerio.load(html) return cheerio.load(html)
} }
...@@ -46,7 +46,7 @@ describe('basic next/dynamic usage', () => { ...@@ -46,7 +46,7 @@ describe('basic next/dynamic usage', () => {
it('should render even there are no physical chunk exists', async () => { it('should render even there are no physical chunk exists', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/no-chunk') browser = await webdriver(next.url, '/dynamic/no-chunk')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Welcome, normal/ /Welcome, normal/
...@@ -65,7 +65,7 @@ describe('basic next/dynamic usage', () => { ...@@ -65,7 +65,7 @@ describe('basic next/dynamic usage', () => {
it('should hydrate nested chunks', async () => { it('should hydrate nested chunks', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/nested') browser = await webdriver(next.url, '/dynamic/nested')
await check(() => browser.elementByCss('body').text(), /Nested 1/) await check(() => browser.elementByCss('body').text(), /Nested 1/)
await check(() => browser.elementByCss('body').text(), /Nested 2/) await check(() => browser.elementByCss('body').text(), /Nested 2/)
await check( await check(
...@@ -92,7 +92,7 @@ describe('basic next/dynamic usage', () => { ...@@ -92,7 +92,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component Head content', async () => { it('should render the component Head content', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/head') browser = await webdriver(next.url, '/dynamic/head')
await check(() => browser.elementByCss('body').text(), /test/) await check(() => browser.elementByCss('body').text(), /test/)
const backgroundColor = await browser const backgroundColor = await browser
.elementByCss('.dynamic-style') .elementByCss('.dynamic-style')
...@@ -119,7 +119,7 @@ describe('basic next/dynamic usage', () => { ...@@ -119,7 +119,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/no-ssr') browser = await webdriver(next.url, '/dynamic/no-ssr')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Hello World 1/ /Hello World 1/
...@@ -142,7 +142,7 @@ describe('basic next/dynamic usage', () => { ...@@ -142,7 +142,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/ssr-true') browser = await webdriver(next.url, '/dynamic/ssr-true')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Hello World 1/ /Hello World 1/
...@@ -174,7 +174,7 @@ describe('basic next/dynamic usage', () => { ...@@ -174,7 +174,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/chunkfilename') browser = await webdriver(next.url, '/dynamic/chunkfilename')
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/test chunkfilename/ /test chunkfilename/
...@@ -196,10 +196,7 @@ describe('basic next/dynamic usage', () => { ...@@ -196,10 +196,7 @@ describe('basic next/dynamic usage', () => {
it('should render the component on client side', async () => { it('should render the component on client side', async () => {
let browser let browser
try { try {
browser = await webdriver( browser = await webdriver(next.url, '/dynamic/no-ssr-custom-loading')
next.appPort,
'/dynamic/no-ssr-custom-loading'
)
await check( await check(
() => browser.elementByCss('body').text(), () => browser.elementByCss('body').text(),
/Hello World 1/ /Hello World 1/
...@@ -223,7 +220,7 @@ describe('basic next/dynamic usage', () => { ...@@ -223,7 +220,7 @@ describe('basic next/dynamic usage', () => {
it('should only load the rendered module in the browser', async () => { it('should only load the rendered module in the browser', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/dynamic/multiple-modules') browser = await webdriver(next.url, '/dynamic/multiple-modules')
const html = await browser.eval('document.documentElement.innerHTML') const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch(/hello1\.js/) expect(html).toMatch(/hello1\.js/)
expect(html).not.toMatch(/hello2\.js/) expect(html).not.toMatch(/hello2\.js/)
......
...@@ -41,10 +41,10 @@ describe.each([ ...@@ -41,10 +41,10 @@ describe.each([
it('should have hydration mismatch with styled-components transform disabled', async () => { it('should have hydration mismatch with styled-components transform disabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
// Compile /_error // Compile /_error
await fetchViaHTTP(next.appPort, '/404') await fetchViaHTTP(next.url, '/404')
try { try {
// Try 4 times to be sure there is no mismatch // Try 4 times to be sure there is no mismatch
......
...@@ -38,10 +38,10 @@ describe('styled-components SWC transform', () => { ...@@ -38,10 +38,10 @@ describe('styled-components SWC transform', () => {
it('should not have hydration mismatch with styled-components transform enabled', async () => { it('should not have hydration mismatch with styled-components transform enabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
// Compile /_error // Compile /_error
await fetchViaHTTP(next.appPort, '/404') await fetchViaHTTP(next.url, '/404')
// Try 4 times to be sure there is no mismatch // Try 4 times to be sure there is no mismatch
expect(await matchLogs$(browser)).toBe(false) expect(await matchLogs$(browser)).toBe(false)
...@@ -59,7 +59,7 @@ describe('styled-components SWC transform', () => { ...@@ -59,7 +59,7 @@ describe('styled-components SWC transform', () => {
}) })
it('should render the page with correct styles', async () => { it('should render the page with correct styles', async () => {
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
expect( expect(
await browser.eval( await browser.eval(
...@@ -75,7 +75,7 @@ describe('styled-components SWC transform', () => { ...@@ -75,7 +75,7 @@ describe('styled-components SWC transform', () => {
it('should enable the display name transform by default', async () => { it('should enable the display name transform by default', async () => {
// make sure the index chunk gets generated // make sure the index chunk gets generated
await webdriver(next.appPort, '/') await webdriver(next.url, '/')
const chunk = await next.readFile('.next/static/chunks/pages/index.js') const chunk = await next.readFile('.next/static/chunks/pages/index.js')
expect(chunk).toContain('displayName: \\"pages__Button\\"') expect(chunk).toContain('displayName: \\"pages__Button\\"')
......
...@@ -29,7 +29,7 @@ describe('TailwindCSS JIT', () => { ...@@ -29,7 +29,7 @@ describe('TailwindCSS JIT', () => {
it('works with JIT enabled', async () => { it('works with JIT enabled', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
const text = await browser.elementByCss('.text-6xl').text() const text = await browser.elementByCss('.text-6xl').text()
expect(text).toMatch(/Welcome to/) expect(text).toMatch(/Welcome to/)
const cssBlue = await browser const cssBlue = await browser
......
...@@ -23,7 +23,7 @@ describe('theme-ui SWC option', () => { ...@@ -23,7 +23,7 @@ describe('theme-ui SWC option', () => {
it('should have theme provided styling', async () => { it('should have theme provided styling', async () => {
let browser let browser
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
const color = await browser.elementByCss('#hello').getComputedCss('color') const color = await browser.elementByCss('#hello').getComputedCss('color')
expect(color).toBe('rgb(51, 51, 238)') expect(color).toBe('rgb(51, 51, 238)')
} finally { } finally {
......
...@@ -23,7 +23,7 @@ describe('Dotenv default expansion', () => { ...@@ -23,7 +23,7 @@ describe('Dotenv default expansion', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
it('should work', async () => { it('should work', async () => {
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('default') expect(text).toBe('default')
......
...@@ -25,7 +25,7 @@ describe('getServerSideProps returns notFound: true', () => { ...@@ -25,7 +25,7 @@ describe('getServerSideProps returns notFound: true', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
it('should not poll indefinitely', async () => { it('should not poll indefinitely', async () => {
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
await waitFor(3000) await waitFor(3000)
await browser.close() await browser.close()
const logOccurrences = next.cliOutput.split('gssp called').length - 1 const logOccurrences = next.cliOutput.split('gssp called').length - 1
......
...@@ -20,7 +20,7 @@ describe('font-loader-in-document-error', () => { ...@@ -20,7 +20,7 @@ describe('font-loader-in-document-error', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
test('@next/font inside _document', async () => { test('@next/font inside _document', async () => {
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.url, '/')
expect(await hasRedbox(browser, true)).toBeTrue() expect(await hasRedbox(browser, true)).toBeTrue()
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"pages/_document.js "pages/_document.js
......
...@@ -22,7 +22,7 @@ describe('app-dir-prefetch-non-iso-url', () => { ...@@ -22,7 +22,7 @@ describe('app-dir-prefetch-non-iso-url', () => {
let browser: BrowserInterface let browser: BrowserInterface
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
await browser.elementByCss('#to-iso').click() await browser.elementByCss('#to-iso').click()
await check(() => browser.elementByCss('#page').text(), '/[slug]') await check(() => browser.elementByCss('#page').text(), '/[slug]')
} finally { } finally {
...@@ -36,7 +36,7 @@ describe('app-dir-prefetch-non-iso-url', () => { ...@@ -36,7 +36,7 @@ describe('app-dir-prefetch-non-iso-url', () => {
let browser: BrowserInterface let browser: BrowserInterface
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
await browser.elementByCss('#to-non-iso').click() await browser.elementByCss('#to-non-iso').click()
await check(() => browser.elementByCss('#page').text(), '/[slug]') await check(() => browser.elementByCss('#page').text(), '/[slug]')
} finally { } finally {
......
...@@ -28,7 +28,7 @@ describe('emitDecoratorMetadata SWC option', () => { ...@@ -28,7 +28,7 @@ describe('emitDecoratorMetadata SWC option', () => {
it('should compile with emitDecoratorMetadata enabled', async () => { it('should compile with emitDecoratorMetadata enabled', async () => {
let browser: BrowserInterface let browser: BrowserInterface
try { try {
browser = await webdriver(next.appPort, '/') browser = await webdriver(next.url, '/')
const message = await browser.elementByCss('#message').text() const message = await browser.elementByCss('#message').text()
expect(message).toBe('Hello, world!') expect(message).toBe('Hello, world!')
......
...@@ -49,7 +49,7 @@ describe('next/jest', () => { ...@@ -49,7 +49,7 @@ describe('next/jest', () => {
afterAll(() => next.destroy()) afterAll(() => next.destroy())
it('data-testid should be removed in production', async () => { it('data-testid should be removed in production', async () => {
const html = await renderViaHTTP(next.appPort, '/') const html = await renderViaHTTP(next.url, '/')
expect(html).not.toContain('data-testid') expect(html).not.toContain('data-testid')
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment