Skip to content

Commit 70ae294

Browse files
committed
test: update snapshot and add unit test for file removal
1 parent 1fb212f commit 70ae294

File tree

2 files changed

+17
-90
lines changed

2 files changed

+17
-90
lines changed

test/__snapshots__/index.spec.ts.snap

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,21 +2082,6 @@ Array [
20822082
"status": 200,
20832083
"to": "/.netlify/functions/___netlify-handler",
20842084
},
2085-
Object {
2086-
"from": "/api/enterPreview",
2087-
"status": 200,
2088-
"to": "/.netlify/functions/api-0",
2089-
},
2090-
Object {
2091-
"from": "/api/exitPreview",
2092-
"status": 200,
2093-
"to": "/.netlify/functions/api-0",
2094-
},
2095-
Object {
2096-
"from": "/api/hello",
2097-
"status": 200,
2098-
"to": "/.netlify/functions/api-0",
2099-
},
21002085
Object {
21012086
"from": "/api/hello-background",
21022087
"status": 200,
@@ -2107,21 +2092,6 @@ Array [
21072092
"status": 404,
21082093
"to": "/404.html",
21092094
},
2110-
Object {
2111-
"from": "/api/revalidate",
2112-
"status": 200,
2113-
"to": "/.netlify/functions/api-0",
2114-
},
2115-
Object {
2116-
"from": "/api/shows/:id",
2117-
"status": 200,
2118-
"to": "/.netlify/functions/api-0",
2119-
},
2120-
Object {
2121-
"from": "/api/shows/:params/*",
2122-
"status": 200,
2123-
"to": "/.netlify/functions/api-0",
2124-
},
21252095
Object {
21262096
"force": false,
21272097
"from": "/app-edge",
@@ -2206,24 +2176,6 @@ Array [
22062176
"status": 200,
22072177
"to": "/.netlify/functions/___netlify-handler",
22082178
},
2209-
Object {
2210-
"force": true,
2211-
"from": "/BUILD_ID",
2212-
"status": 404,
2213-
"to": "/404.html",
2214-
},
2215-
Object {
2216-
"force": true,
2217-
"from": "/build-manifest.json",
2218-
"status": 404,
2219-
"to": "/404.html",
2220-
},
2221-
Object {
2222-
"force": true,
2223-
"from": "/cache/*",
2224-
"status": 404,
2225-
"to": "/404.html",
2226-
},
22272179
Object {
22282180
"force": false,
22292181
"from": "/css",
@@ -2883,54 +2835,24 @@ Array [
28832835
"status": 200,
28842836
"to": "/.netlify/functions/___netlify-handler",
28852837
},
2886-
Object {
2887-
"force": true,
2888-
"from": "/prerender-manifest.json",
2889-
"status": 404,
2890-
"to": "/404.html",
2891-
},
28922838
Object {
28932839
"force": false,
28942840
"from": "/previewTest",
28952841
"status": 200,
28962842
"to": "/.netlify/functions/___netlify-handler",
28972843
},
2898-
Object {
2899-
"force": true,
2900-
"from": "/react-loadable-manifest.json",
2901-
"status": 404,
2902-
"to": "/404.html",
2903-
},
29042844
Object {
29052845
"force": false,
29062846
"from": "/redirectme",
29072847
"status": 200,
29082848
"to": "/.netlify/functions/___netlify-handler",
29092849
},
2910-
Object {
2911-
"force": true,
2912-
"from": "/routes-manifest.json",
2913-
"status": 404,
2914-
"to": "/404.html",
2915-
},
29162850
Object {
29172851
"force": false,
29182852
"from": "/script",
29192853
"status": 200,
29202854
"to": "/.netlify/functions/___netlify-handler",
29212855
},
2922-
Object {
2923-
"force": true,
2924-
"from": "/server/*",
2925-
"status": 404,
2926-
"to": "/404.html",
2927-
},
2928-
Object {
2929-
"force": true,
2930-
"from": "/serverless/*",
2931-
"status": 404,
2932-
"to": "/404.html",
2933-
},
29342856
Object {
29352857
"force": false,
29362858
"from": "/shows/:id",
@@ -2966,17 +2888,5 @@ Array [
29662888
"status": 200,
29672889
"to": "/.netlify/functions/___netlify-handler",
29682890
},
2969-
Object {
2970-
"force": true,
2971-
"from": "/trace",
2972-
"status": 404,
2973-
"to": "/404.html",
2974-
},
2975-
Object {
2976-
"force": true,
2977-
"from": "/traces",
2978-
"status": 404,
2979-
"to": "/404.html",
2980-
},
29812891
]
29822892
`;

test/index.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,23 @@ describe('onPostBuild', () => {
10311031
},
10321032
])
10331033
})
1034+
1035+
it(`removes metadata files`, async () => {
1036+
await moveNextDist()
1037+
1038+
// routes-manifest.json is one of metadata files that seems to be created with default demo site
1039+
// there are a lot of other files, but we will test just one
1040+
const manifestPath = path.resolve('.next/routes-manifest.json')
1041+
1042+
expect(await pathExists(manifestPath)).toBe(true)
1043+
1044+
await nextRuntime.onPostBuild({
1045+
...defaultArgs,
1046+
utils: { ...utils, cache: { save: jest.fn() }, functions: { list: jest.fn().mockResolvedValue([]) } },
1047+
})
1048+
1049+
expect(await pathExists(manifestPath)).toBe(false)
1050+
})
10341051
})
10351052

10361053
describe('function helpers', () => {

0 commit comments

Comments
 (0)