Unverified Commit d715c13f authored by Matt Snider's avatar Matt Snider Committed by GitHub

Custom AMP Validator Variable Name Collision Fix (#10371)

* Changing variable name internally

* Add tests for custom AMP validator
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 9ba4bee2
...@@ -232,7 +232,7 @@ export default async function( ...@@ -232,7 +232,7 @@ export default async function(
hotReloader: null, hotReloader: null,
canonicalBase: nextConfig.amp?.canonicalBase || '', canonicalBase: nextConfig.amp?.canonicalBase || '',
isModern: nextConfig.experimental.modern, isModern: nextConfig.experimental.modern,
ampValidator: nextConfig.experimental.amp?.validator || undefined, ampValidatorPath: nextConfig.experimental.amp?.validator || undefined,
} }
const { serverRuntimeConfig, publicRuntimeConfig } = nextConfig const { serverRuntimeConfig, publicRuntimeConfig } = nextConfig
......
...@@ -214,7 +214,7 @@ export default async function({ ...@@ -214,7 +214,7 @@ export default async function({
} }
if (curRenderOpts.inAmpMode) { if (curRenderOpts.inAmpMode) {
await validateAmp(html, path, curRenderOpts.ampValidator) await validateAmp(html, path, curRenderOpts.ampValidatorPath)
} else if (curRenderOpts.hybridAmp) { } else if (curRenderOpts.hybridAmp) {
// we need to render the AMP version // we need to render the AMP version
let ampHtmlFilename = `${ampPath}${sep}index.html` let ampHtmlFilename = `${ampPath}${sep}index.html`
......
module.exports = {
experimental: {
amp: {
validator: 'https://cdn.ampproject.org/v0/validator.js',
},
},
}
export const config = {
amp: true,
}
export default () => <p>Hello from AMP</p>
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import {
nextBuild,
findPort,
nextStart,
killApp,
launchApp,
renderViaHTTP,
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
let app
let appPort
const appDir = join(__dirname, '../')
describe('AMP Custom Validator', () => {
it('should build and start successfully', async () => {
const { code } = await nextBuild(appDir)
expect(code).toBe(0)
appPort = await findPort()
app = await nextStart(appDir, appPort)
const html = await renderViaHTTP(appPort, '/')
await killApp(app)
expect(html).toContain('Hello from AMP')
})
it('should run in dev mode successfully', async () => {
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
const html = await renderViaHTTP(appPort, '/')
await killApp(app)
expect(stderr).not.toContain('error')
expect(html).toContain('Hello from AMP')
})
})
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