Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit 2d5e867

Browse files
committed
fix 404 cypress tests which expect root level 404.html
1 parent db05c51 commit 2d5e867

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cypress/integration/i18n_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ describe("getServerSideProps", () => {
210210
cy.state("document").write(response.body);
211211
});
212212

213-
// cy.get("h2").should("contain", "This page could not be found.");
213+
cy.get("h2").should("contain", "This page could not be found.");
214214
});
215215

216216
it("loads TV show with one param", () => {
@@ -328,7 +328,7 @@ describe("getStaticProps", () => {
328328
cy.state("document").write(response.body);
329329
});
330330

331-
// cy.get("h2").should("contain", "This page could not be found.");
331+
cy.get("h2").should("contain", "This page could not be found.");
332332
});
333333
});
334334

@@ -704,6 +704,6 @@ describe("404 page", () => {
704704
cy.state("document").write(response.body);
705705
});
706706

707-
// cy.get("h2").should("contain", "This page could not be found.");
707+
cy.get("h2").should("contain", "This page could not be found.");
708708
});
709709
});

lib/pages/withoutProps/setup.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { join, relative } = require("path");
22
const { copySync } = require("fs-extra");
33
const { logTitle, logItem } = require("../../helpers/logger");
44
const { NEXT_DIST_DIR } = require("../../config");
5+
const nextConfig = require("../../helpers/getNextConfig")();
56
const setupStaticFileForPage = require("../../helpers/setupStaticFileForPage");
67
const pages = require("./pages");
78

@@ -14,6 +15,17 @@ const setup = (publishPath) => {
1415
pages.forEach(({ filePath }) => {
1516
logItem(filePath);
1617

18+
// HACK: If i18n, Next internals expect a 404.html at the top level of the publish directory
19+
// TO-DO: investigate framework and why this isn't an issue on Vercel and only certain routes
20+
if (nextConfig.i18n) {
21+
if (filePath === `pages/${nextConfig.i18n.defaultLocale}/404.html`) {
22+
copySync(
23+
join(NEXT_DIST_DIR, "serverless", filePath),
24+
join(publishPath, "404.html")
25+
);
26+
}
27+
}
28+
1729
// The path to the file, relative to the pages directory
1830
const relativePath = relative("pages", filePath);
1931
setupStaticFileForPage({ inputPath: relativePath, publishPath });

0 commit comments

Comments
 (0)