Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for universal webpack (#3680)
* Add tests for universal webpack * Move tests to next-plugins * Remove obsolete files * Remove removed page * Remove tests * Rename test suite
- Loading branch information
1 parent
70295f2
commit ed12293
Showing
13 changed files
with
757 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
onDemandEntries: { | ||
// Make sure entries are not getting disposed. | ||
maxInactiveAge: 1000 * 60 * 60 | ||
} | ||
} |
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 @@ | ||
!node_modules |
3 changes: 3 additions & 0 deletions
3
test/integration/next-plugins/components/hello-webpack-css.css
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 @@ | ||
.helloWorld { | ||
color: red; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/integration/next-plugins/components/hello-webpack-css.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 @@ | ||
import css from './hello-webpack-css.css' | ||
import framework from 'css-framework/framework.css' | ||
export default () => <div className={`${css.helloWorld} ${framework.frameworkClass}`}>Hello World</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,9 @@ | ||
const withCSS = require('@zeit/next-css') | ||
|
||
module.exports = withCSS({ | ||
onDemandEntries: { | ||
// Make sure entries are not getting disposed. | ||
maxInactiveAge: 1000 * 60 * 60 | ||
}, | ||
cssModules: true | ||
}) |
3 changes: 3 additions & 0 deletions
3
test/integration/next-plugins/node_modules/css-framework/framework.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
import HelloWebpackCSS from '../components/hello-webpack-css' | ||
|
||
export default () => <HelloWebpackCSS /> |
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,31 @@ | ||
/* global jasmine, describe, beforeAll, afterAll */ | ||
|
||
import { join } from 'path' | ||
import { | ||
renderViaHTTP, | ||
fetchViaHTTP, | ||
findPort, | ||
launchApp, | ||
killApp | ||
} from 'next-test-utils' | ||
|
||
// test suits | ||
import rendering from './rendering' | ||
|
||
const context = {} | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5 | ||
|
||
describe('Next Plugins', () => { | ||
beforeAll(async () => { | ||
context.appPort = await findPort() | ||
context.server = await launchApp(join(__dirname, '../'), context.appPort, true) | ||
|
||
// pre-build all pages at the start | ||
await Promise.all([ | ||
renderViaHTTP(context.appPort, '/webpack-css') | ||
]) | ||
}) | ||
afterAll(() => killApp(context.server)) | ||
|
||
rendering(context, 'Rendering via HTTP', (p, q) => renderViaHTTP(context.appPort, p, q), (p, q) => fetchViaHTTP(context.appPort, p, q)) | ||
}) |
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,22 @@ | ||
/* global describe, test, expect */ | ||
|
||
import cheerio from 'cheerio' | ||
|
||
export default function ({ app }, suiteName, render, fetch) { | ||
async function get$ (path, query) { | ||
const html = await render(path, query) | ||
return cheerio.load(html) | ||
} | ||
|
||
describe(suiteName, () => { | ||
test('renders css imports', async () => { | ||
const $ = await get$('/webpack-css') | ||
expect($('._46QtCORzC4BWRnIseSbG-').text() === 'Hello World') | ||
}) | ||
|
||
test('renders non-js imports from node_modules', async () => { | ||
const $ = await get$('/webpack-css') | ||
expect($('._2pRSkKTPDMGLMnmsEkP__J').text() === 'Hello World') | ||
}) | ||
}) | ||
} |
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,6 @@ | ||
module.exports = { | ||
onDemandEntries: { | ||
// Make sure entries are not getting disposed. | ||
maxInactiveAge: 1000 * 60 * 60 | ||
} | ||
} |
Oops, something went wrong.