Skip to content

Commit 8ae0685

Browse files
committed
add some initial lightweight testing
1 parent 823a55a commit 8ae0685

File tree

9 files changed

+13260
-3917
lines changed

9 files changed

+13260
-3917
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ yarn-debug.log*
77
yarn-error.log*
88
lerna-debug.log*
99

10+
# Tests
11+
next.config.js
12+
1013
# Diagnostic reports (https://nodejs.org/api/report.html)
1114
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1215

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ node_modules
1515
# Optional REPL history
1616
.node_repl_history
1717
.next
18+
19+
# Test
20+
next.config.js
21+
__mocks__

__mocks__/cpx.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
copySync: jest.fn()
3+
};

__mocks__/make-dir.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = jest.fn();

__mocks__/next-on-netlify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = jest.fn();

index.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
const fs = require('fs')
2-
const { existsSync, readFileSync } = require('fs')
1+
const { existsSync, readFileSync, appendFileSync } = require('fs')
32
const path = require('path')
4-
const { appendFile, readdir } = require('fs').promises
5-
const { hasFramework } = require('@netlify/framework-info')
63
const nextOnNetlify = require('next-on-netlify')
74
const { PHASE_PRODUCTION_BUILD } = require('next/constants')
85
const { default: loadConfig } = require('next/dist/next-server/server/config')
@@ -15,13 +12,8 @@ const isStaticExportProject = require('./helpers/isStaticExportProject')
1512
// - Between the build and postbuild steps, any functions are bundled
1613

1714
module.exports = {
18-
async onPreBuild({ netlifyConfig, packageJson: { scripts = {}, dependencies = {} }, utils }) {
15+
async onPreBuild({ netlifyConfig = {}, packageJson: { scripts = {}, dependencies = {} }, utils }) {
1916
const { failBuild } = utils.build
20-
21-
if (!(await hasFramework('next'))) {
22-
return failBuild(`This application does not use Next.js.`)
23-
}
24-
2517
const { build } = netlifyConfig
2618
// TO-DO: Post alpha, try to remove this workaround for missing deps in
2719
// the next-on-netlify function template
@@ -61,7 +53,7 @@ module.exports = {
6153
target: 'serverless'
6254
}
6355
`
64-
await appendFile('next.config.js', nextConfig)
56+
appendFileSync('next.config.js', nextConfig)
6557
console.log(`** Adding next.config.js with target set to 'serverless' **`)
6658
}
6759
},

0 commit comments

Comments
 (0)