|
| 1 | +/* eslint-disable max-lines */ |
| 2 | +/* eslint-disable max-lines-per-function */ |
1 | 3 | const path = require('path')
|
2 | 4 | const process = require('process')
|
3 | 5 |
|
@@ -156,6 +158,33 @@ describe('preBuild()', () => {
|
156 | 158 | expect(process.env.NEXT_PRIVATE_TARGET).toBeUndefined()
|
157 | 159 | })
|
158 | 160 |
|
| 161 | + test('do nothing if build command includes "build-storybook"', async () => { |
| 162 | + await plugin.onPreBuild({ |
| 163 | + netlifyConfig, |
| 164 | + packageJson: { ...DUMMY_PACKAGE_JSON, scripts: { build: 'build-storybook' } }, |
| 165 | + utils, |
| 166 | + }) |
| 167 | + expect(process.env.NEXT_PRIVATE_TARGET).toBeUndefined() |
| 168 | + }) |
| 169 | + |
| 170 | + test('do nothing if build command calls a script that includes "build-storybook"', async () => { |
| 171 | + await plugin.onPreBuild({ |
| 172 | + netlifyConfig: { build: { command: 'npm run storybook' } }, |
| 173 | + packageJson: { ...DUMMY_PACKAGE_JSON, scripts: { storybook: 'build-storybook' } }, |
| 174 | + utils, |
| 175 | + }) |
| 176 | + expect(process.env.NEXT_PRIVATE_TARGET).toBeUndefined() |
| 177 | + }) |
| 178 | + |
| 179 | + test('run plugin if app has build-storybook in an unused script', async () => { |
| 180 | + await plugin.onPreBuild({ |
| 181 | + netlifyConfig, |
| 182 | + packageJson: { ...DUMMY_PACKAGE_JSON, scripts: { storybook: 'build-storybook' } }, |
| 183 | + utils, |
| 184 | + }) |
| 185 | + expect(process.env.NEXT_PRIVATE_TARGET).toBe('serverless') |
| 186 | + }) |
| 187 | + |
159 | 188 | test('fail build if the app has no package.json', async () => {
|
160 | 189 | await expect(
|
161 | 190 | plugin.onPreBuild({
|
@@ -289,3 +318,6 @@ describe('onPostBuild', () => {
|
289 | 318 | expect(path.normalize(manifestPath.digests[0])).toBe(path.normalize('build/build-manifest.json'))
|
290 | 319 | })
|
291 | 320 | })
|
| 321 | + |
| 322 | +/* eslint-enable max-lines */ |
| 323 | +/* eslint-enable max-lines-per-function */ |
0 commit comments