-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to error on usage of serverRuntimeConfig with serverless (#9030)
* Update to error on usage of serverRuntimeConfig with serverless * Add tests for errors for serverless and runtime configs * Update docs wording
- Loading branch information
Showing
6 changed files
with
65 additions
and
10 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
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
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 @@ | ||
export default () => 'hi' |
50 changes: 50 additions & 0 deletions
50
test/integration/serverless-runtime-configs/test/index.test.js
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,50 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import fs from 'fs-extra' | ||
import { join } from 'path' | ||
import { nextBuild } from 'next-test-utils' | ||
|
||
const appDir = join(__dirname, '../') | ||
const nextConfigPath = join(appDir, 'next.config.js') | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 | ||
|
||
const cleanUp = () => fs.remove(nextConfigPath) | ||
|
||
describe('Serverless runtime configs', () => { | ||
beforeAll(() => cleanUp()) | ||
afterAll(() => cleanUp()) | ||
|
||
it('should error on usage of publicRuntimeConfig', async () => { | ||
await fs.writeFile( | ||
nextConfigPath, | ||
`module.exports = { | ||
target: 'serverless', | ||
publicRuntimeConfig: { | ||
hello: 'world' | ||
} | ||
}` | ||
) | ||
|
||
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) | ||
expect(stderr).toMatch( | ||
/Cannot use publicRuntimeConfig or serverRuntimeConfig/ | ||
) | ||
}) | ||
|
||
it('should error on usage of serverRuntimeConfig', async () => { | ||
await fs.writeFile( | ||
nextConfigPath, | ||
`module.exports = { | ||
target: 'serverless', | ||
serverRuntimeConfig: { | ||
hello: 'world' | ||
} | ||
}` | ||
) | ||
|
||
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) | ||
expect(stderr).toMatch( | ||
/Cannot use publicRuntimeConfig or serverRuntimeConfig/ | ||
) | ||
}) | ||
}) |