提交 e1cf32ca 编写于 作者: J JJ Kasper 提交者: Joe Haddad

Update export tests and fixed import (#6738)

* Fix import in export worker

* Update export tests

* Turn test parallelism up

* Fix config in export-default-map

* Switch parallelism back to 3
上级 b5880717
import mkdirpModule from 'mkdirp'
import { promisify } from 'util'
import { cleanAmpPath } from 'next/dist/server/lib/utils'
import { extname, join, dirname, sep } from 'path'
import { cleanAmpPath } from 'next-server/dist/server/utils'
import { renderToHTML } from 'next-server/dist/server/render'
import { writeFile } from 'fs'
import Sema from 'async-sema'
......
module.exports = {
experimental: {
amp: true
}
}
export default () => (
<p>I'm an AMP page</p>
)
export default () => (
<p>I'm an AMP page</p>
)
/* eslint-env jest */
/* global jasmine */
import fs from 'fs'
import { join } from 'path'
import { promisify } from 'util'
import {
nextBuild,
nextExport
} from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
const access = promisify(fs.access)
const appDir = join(__dirname, '../')
const outdir = join(appDir, 'out')
describe('Export with default map', () => {
beforeAll(async () => {
await nextBuild(appDir)
await nextExport(appDir, { outdir })
})
it('should export with folder that has dot in name', async () => {
expect.assertions(1)
await expect(access(join(outdir, 'v1.12/index.html'))).resolves.toBe(undefined)
})
it('should export an amp only page to clean path', async () => {
expect.assertions(1)
await expect(access(join(outdir, 'docs/index.html'))).resolves.toBe(undefined)
})
it('should export hybrid amp page correctly', async () => {
expect.assertions(2)
await expect(access(join(outdir, 'some/index.html'))).resolves.toBe(undefined)
await expect(access(join(outdir, 'some.amp/index.html'))).resolves.toBe(undefined)
})
})
......@@ -30,22 +30,6 @@ const devContext = {}
const nextConfig = new File(join(appDir, 'next.config.js'))
describe('Static Export', () => {
it('should export with folder that has dot in name', async () => {
const outdir = join(appDir, 'out')
nextConfig.replace(/exportPathMap: function (.|\n|\r\n)*end exportPathMap/gm, '// disabled exportPathMap')
await nextBuild(appDir)
await nextExport(appDir, { outdir })
let doesExists = true
await access(join(outdir, 'v1.12/index.html'))
.then(() => {
doesExists = true
})
expect(doesExists).toBe(true)
nextConfig.restore()
})
it('should delete existing exported files', async () => {
const outdir = join(appDir, 'out')
const tempfile = join(outdir, 'temp.txt')
......@@ -72,6 +56,7 @@ describe('Static Export', () => {
nextConfig.replace(`// exportTrailingSlash: false`, `exportTrailingSlash: false`)
await nextBuild(appDir)
await nextExport(appDir, { outdir: outNoTrailSlash })
nextConfig.restore()
context.server = await startStaticServer(join(appDir, 'out'))
context.port = context.server.address().port
......@@ -94,7 +79,6 @@ describe('Static Export', () => {
killApp(devContext.server),
stopApp(context.serverNoTrailSlash)
])
nextConfig.restore()
})
ssr(context)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册