-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into disable-css-when-custom
- Loading branch information
Showing
17 changed files
with
292 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/out |
5 changes: 5 additions & 0 deletions
5
test/integration/export-intent/fixtures/bad-export/pages/index.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,5 @@ | ||
const A = () => { | ||
throw new Error('fail da export') | ||
} | ||
A.getInitialProps = () => {} | ||
export default A |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/custom-export/.gitignore
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 @@ | ||
/out |
5 changes: 5 additions & 0 deletions
5
test/integration/export-intent/fixtures/custom-export/next.config.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,5 @@ | ||
module.exports = { | ||
exportPathMap() { | ||
return { '/': { page: '/' } } | ||
}, | ||
} |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/custom-export/pages/index.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 @@ | ||
export default () => <div>Hello Export</div> |
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 @@ | ||
/lel |
3 changes: 3 additions & 0 deletions
3
test/integration/export-intent/fixtures/custom-out/next.config.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,3 @@ | ||
module.exports = { | ||
exportTrailingSlash: true, | ||
} |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/custom-out/pages/index.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 @@ | ||
export default () => <div>Hello Export</div> |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/default-export/.gitignore
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 @@ | ||
/out |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/default-export/pages/index.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 @@ | ||
export default () => <div>Hello Export</div> |
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 @@ | ||
/out |
1 change: 1 addition & 0 deletions
1
test/integration/export-intent/fixtures/no-export/pages/index.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 @@ | ||
export default () => <div>Hello Export</div> |
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,217 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import { remove } from 'fs-extra' | ||
import { nextBuild, nextExport, nextExportDefault } from 'next-test-utils' | ||
import path, { join } from 'path' | ||
import fs from 'fs' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 | ||
|
||
const fixturesDir = join(__dirname, '..', 'fixtures') | ||
|
||
describe('Application Export Intent Output', () => { | ||
describe('Default Export', () => { | ||
const appDir = join(fixturesDir, 'default-export') | ||
const distDir = join(appDir, '.next') | ||
|
||
beforeAll(async () => { | ||
await remove(distDir) | ||
}) | ||
|
||
it('should build and export', async () => { | ||
await nextBuild(appDir) | ||
await nextExportDefault(appDir) | ||
}) | ||
|
||
it('should have the expected outputs for export', () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"exportTrailingSlash": false, | ||
"hasExportPathMap": false, | ||
"version": 1, | ||
} | ||
`) | ||
|
||
const detail = JSON.parse( | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
) | ||
expect({ | ||
...detail, | ||
outDirectory: path.basename(detail.outDirectory), | ||
}).toMatchInlineSnapshot(` | ||
Object { | ||
"outDirectory": "out", | ||
"success": true, | ||
"version": 1, | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
describe('Custom Export', () => { | ||
const appDir = join(fixturesDir, 'custom-export') | ||
const distDir = join(appDir, '.next') | ||
|
||
beforeAll(async () => { | ||
await remove(distDir) | ||
}) | ||
|
||
it('should build and export', async () => { | ||
await nextBuild(appDir) | ||
await nextExportDefault(appDir) | ||
}) | ||
|
||
it('should have the expected outputs for export', () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"exportTrailingSlash": false, | ||
"hasExportPathMap": true, | ||
"version": 1, | ||
} | ||
`) | ||
|
||
const detail = JSON.parse( | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
) | ||
expect({ | ||
...detail, | ||
outDirectory: path.basename(detail.outDirectory), | ||
}).toMatchInlineSnapshot(` | ||
Object { | ||
"outDirectory": "out", | ||
"success": true, | ||
"version": 1, | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
describe('Custom Out', () => { | ||
const appDir = join(fixturesDir, 'custom-out') | ||
const distDir = join(appDir, '.next') | ||
|
||
beforeAll(async () => { | ||
await remove(distDir) | ||
}) | ||
|
||
it('should build and export', async () => { | ||
await nextBuild(appDir) | ||
await nextExport(appDir, { outdir: join(appDir, 'lel') }) | ||
}) | ||
|
||
it('should have the expected outputs for export', () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"exportTrailingSlash": true, | ||
"hasExportPathMap": false, | ||
"version": 1, | ||
} | ||
`) | ||
|
||
const detail = JSON.parse( | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
) | ||
expect({ | ||
...detail, | ||
outDirectory: path.basename(detail.outDirectory), | ||
}).toMatchInlineSnapshot(` | ||
Object { | ||
"outDirectory": "lel", | ||
"success": true, | ||
"version": 1, | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
describe('Bad Export', () => { | ||
const appDir = join(fixturesDir, 'bad-export') | ||
const distDir = join(appDir, '.next') | ||
|
||
beforeAll(async () => { | ||
await remove(distDir) | ||
}) | ||
|
||
it('should build and export', async () => { | ||
await nextBuild(appDir) | ||
await nextExportDefault(appDir) | ||
}) | ||
|
||
it('should have the expected outputs for export', () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"exportTrailingSlash": false, | ||
"hasExportPathMap": false, | ||
"version": 1, | ||
} | ||
`) | ||
|
||
const detail = JSON.parse( | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
) | ||
expect({ | ||
...detail, | ||
outDirectory: path.basename(detail.outDirectory), | ||
}).toMatchInlineSnapshot(` | ||
Object { | ||
"outDirectory": "out", | ||
"success": false, | ||
"version": 1, | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
describe('No Export', () => { | ||
const appDir = join(fixturesDir, 'no-export') | ||
const distDir = join(appDir, '.next') | ||
|
||
beforeAll(async () => { | ||
await remove(distDir) | ||
}) | ||
|
||
it('should build and not export', async () => { | ||
await nextBuild(appDir) | ||
}) | ||
|
||
it('should have the expected outputs for export', () => { | ||
expect( | ||
JSON.parse(fs.readFileSync(join(distDir, 'export-marker.json'), 'utf8')) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"exportTrailingSlash": false, | ||
"hasExportPathMap": false, | ||
"version": 1, | ||
} | ||
`) | ||
|
||
expect(() => { | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
}).toThrowError(/ENOENT/) | ||
}) | ||
|
||
it('should export and create file', async () => { | ||
await nextExportDefault(appDir) | ||
|
||
expect(() => { | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
}).not.toThrow() | ||
}) | ||
|
||
it('should build and clean up', async () => { | ||
await nextBuild(appDir) | ||
|
||
expect(() => { | ||
fs.readFileSync(join(distDir, 'export-detail.json'), 'utf8') | ||
}).toThrowError(/ENOENT/) | ||
}) | ||
}) | ||
}) |
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