Skip to content

Commit 8513880

Browse files
Merge pull request #12 from netlify/use-demo-for-tests
chore: use demo for tests instead of test/sample
2 parents a9d74ea + 0aef612 commit 8513880

File tree

9 files changed

+16
-31
lines changed

9 files changed

+16
-31
lines changed

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prepublishOnly:pull": "git pull",
2525
"prepublishOnly:install": "npm ci",
2626
"prepublishOnly:test": "npm test",
27-
"test": "next build test/sample && jest",
27+
"test": "run-s build:demo test:jest",
28+
"test:jest": "jest",
2829
"prepare": "npm run build",
2930
"clean": "rimraf lib",
3031
"build": "unbuild"

Diff for: test/__snapshots__/index.js.snap

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
exports[`onBuild() writes correct redirects to netlifyConfig 1`] = `
44
"/_next/image* /_ipx/w_:width,q_:quality/:url 301
55
/_ipx/* /.netlify/functions/_ipx 200
6+
/_next/data/%BUILD_ID%/getStaticProps/withFallback/:id.json /.netlify/functions/___netlify-odb-handler 200
7+
/_next/data/%BUILD_ID%/getStaticProps/withFallback/:slug/* /.netlify/functions/___netlify-odb-handler 200
8+
/_next/data/%BUILD_ID%/getStaticProps/withFallbackBlocking/:id.json /.netlify/functions/___netlify-odb-handler 200
9+
/_next/data/%BUILD_ID%/getStaticProps/withRevalidate/withFallback/:id.json /.netlify/functions/___netlify-odb-handler 200
10+
/getStaticProps/withFallback/:id /.netlify/functions/___netlify-odb-handler 200
11+
/getStaticProps/withFallback/:slug/* /.netlify/functions/___netlify-odb-handler 200
12+
/getStaticProps/withFallbackBlocking/:id /.netlify/functions/___netlify-odb-handler 200
13+
/getStaticProps/withRevalidate/withFallback/:id /.netlify/functions/___netlify-odb-handler 200
614
/_next/static/* /static/:splat 200
715
/* /.netlify/functions/___netlify-handler 200
816
"

Diff for: test/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const getNextConfig = require('../src/helpers/getNextConfig')
1313
const usesBuildCommand = require('../src/helpers/usesBuildCommand')
1414

1515
const FIXTURES_DIR = `${__dirname}/fixtures`
16-
const SAMPLE_PROJECT_DIR = `${__dirname}/sample`
16+
const SAMPLE_PROJECT_DIR = `${__dirname}/../demo`
1717

1818
const utils = {
1919
build: {
@@ -302,10 +302,14 @@ describe('onBuild()', () => {
302302
utils,
303303
})
304304

305-
const redirects = netlifyConfig.redirects.reduce((acc, curr) => {
305+
let redirects = netlifyConfig.redirects.reduce((acc, curr) => {
306306
const { from, to, status } = curr
307307
return acc + `${from} ${to} ${status}\n`
308308
}, '')
309+
310+
// Replace non-persistent build ID with placeholder
311+
redirects = redirects.replace(/\/_next\/data\/[^\/]+\//g, '/_next/data/%BUILD_ID%/')
312+
309313
expect(redirects).toMatchSnapshot()
310314
})
311315

Diff for: test/sample/.eslintrc

-4
This file was deleted.

Diff for: test/sample/netlify.toml

-6
This file was deleted.

Diff for: test/sample/next.config.js

-1
This file was deleted.

Diff for: test/sample/pages/_app.js

-5
This file was deleted.

Diff for: test/sample/pages/api/test.js

-5
This file was deleted.

Diff for: test/sample/pages/index.js

-7
This file was deleted.

0 commit comments

Comments
 (0)