-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` The PR fixes #30300 and #36855. The corresponding integration test case has been added.
- Loading branch information
Showing
5 changed files
with
70 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = (phase) => { | ||
return { | ||
trailingSlash: false, | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-env jest */ | ||
|
||
import { promises } from 'fs' | ||
import { join } from 'path' | ||
import { nextBuild, nextExport, File } from 'next-test-utils' | ||
|
||
const { readFile, access, stat } = promises | ||
const appDir = join(__dirname, '../') | ||
const outdir = join(appDir, 'out') | ||
|
||
const nextConfig = new File(join(appDir, 'next.config.js')) | ||
|
||
const fileExist = (path) => | ||
access(path) | ||
.then(() => stat(path)) | ||
.then((stats) => (stats.isFile() ? true : false)) | ||
.catch(() => false) | ||
|
||
// Issue #36855 | ||
// https://github.com/vercel/next.js/issues/36855 | ||
describe('Static 404 Export', () => { | ||
it('only export 404.html when trailingSlash: false', async () => { | ||
await nextBuild(appDir) | ||
await nextExport(appDir, { outdir }) | ||
|
||
expect(await fileExist(join(outdir, '404.html'))).toBe(true) | ||
expect(await fileExist(join(outdir, '404.html.html'))).toBe(false) | ||
expect(await fileExist(join(outdir, '404/index.html'))).toBe(false) | ||
}) | ||
|
||
it('export 404.html and 404/index.html when trailingSlash: true', async () => { | ||
nextConfig.replace(`trailingSlash: false`, `trailingSlash: true`) | ||
await nextBuild(appDir) | ||
await nextExport(appDir, { outdir }) | ||
nextConfig.restore() | ||
|
||
expect(await fileExist(join(outdir, '404/index.html'))).toBe(true) | ||
expect(await fileExist(join(outdir, '404.html.html'))).toBe(false) | ||
expect(await fileExist(join(outdir, '404.html'))).toBe(true) | ||
}) | ||
}) | ||
|
||
describe('Export with a page named 404.js', () => { | ||
it('should export a custom 404.html instead of default 404.html', async () => { | ||
await nextBuild(appDir) | ||
await nextExport(appDir, { outdir }) | ||
|
||
const html = await readFile(join(outdir, '404.html'), 'utf8') | ||
expect(html).toMatch(/this is a 404 page override the default 404\.html/) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.