Unverified Commit be02b881 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix auto export in serverless (#7517)

* Fix nextExport not being set in serverless

* Add test for refreshing query
parent 66fd87fc
...@@ -72,6 +72,7 @@ const nextServerlessLoader: loader.Loader = function() { ...@@ -72,6 +72,7 @@ const nextServerlessLoader: loader.Loader = function() {
{ {
Component, Component,
dataOnly: req.headers && (req.headers.accept || '').indexOf('application/amp.bind+json') !== -1, dataOnly: req.headers && (req.headers.accept || '').indexOf('application/amp.bind+json') !== -1,
nextExport: fromExport
}, },
options, options,
) )
......
module.exports = {
target: 'serverless',
experimental: {
autoExport: true,
dynamicRouting: true
}
}
import { useRouter } from 'next/router'
export default () => {
const { query } = useRouter()
return <p>post: {query.post}</p>
}
/* eslint-env jest */
/* global jasmine */
import webdriver from 'next-webdriver'
import path from 'path'
import { nextBuild, nextStart, findPort, killApp } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
const appDir = path.join(__dirname, '..')
let appPort
let app
describe('Auto Export Serverless', () => {
it('Refreshes query on mount', async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
const browser = await webdriver(appPort, '/post-1')
const html = await browser.eval('document.body.innerHTML')
expect(html).toMatch(/post.*post-1/)
expect(html).toMatch(/nextExport/)
await killApp(app)
await browser.close()
})
})
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