mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
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
This commit is contained in:
parent
70295f2e87
commit
ed122934af
|
@ -113,6 +113,7 @@
|
|||
"@taskr/clear": "1.1.0",
|
||||
"@taskr/esnext": "1.1.0",
|
||||
"@taskr/watch": "1.1.0",
|
||||
"@zeit/next-css": "0.0.7",
|
||||
"babel-eslint": "8.0.1",
|
||||
"babel-jest": "21.2.0",
|
||||
"babel-plugin-istanbul": "4.1.5",
|
||||
|
|
|
@ -35,6 +35,7 @@ describe('Basic Features', () => {
|
|||
renderViaHTTP(context.appPort, '/link'),
|
||||
renderViaHTTP(context.appPort, '/stateful'),
|
||||
renderViaHTTP(context.appPort, '/stateless'),
|
||||
renderViaHTTP(context.appPort, '/custom-extension'),
|
||||
renderViaHTTP(context.appPort, '/styled-jsx'),
|
||||
renderViaHTTP(context.appPort, '/with-cdm'),
|
||||
|
||||
|
|
6
test/integration/custom-server/next.config.js
Normal file
6
test/integration/custom-server/next.config.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
onDemandEntries: {
|
||||
// Make sure entries are not getting disposed.
|
||||
maxInactiveAge: 1000 * 60 * 60
|
||||
}
|
||||
}
|
1
test/integration/next-plugins/.gitignore
vendored
Normal file
1
test/integration/next-plugins/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!node_modules
|
|
@ -0,0 +1,3 @@
|
|||
.helloWorld {
|
||||
color: red;
|
||||
}
|
|
@ -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>
|
9
test/integration/next-plugins/next.config.js
Normal file
9
test/integration/next-plugins/next.config.js
Normal file
|
@ -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
test/integration/next-plugins/node_modules/css-framework/framework.css
generated
vendored
Normal file
3
test/integration/next-plugins/node_modules/css-framework/framework.css
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.frameworkClass {
|
||||
font-size: 100px;
|
||||
}
|
3
test/integration/next-plugins/pages/webpack-css.js
Normal file
3
test/integration/next-plugins/pages/webpack-css.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import HelloWebpackCSS from '../components/hello-webpack-css'
|
||||
|
||||
export default () => <HelloWebpackCSS />
|
31
test/integration/next-plugins/test/index.test.js
Normal file
31
test/integration/next-plugins/test/index.test.js
Normal file
|
@ -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))
|
||||
})
|
22
test/integration/next-plugins/test/rendering.js
Normal file
22
test/integration/next-plugins/test/rendering.js
Normal file
|
@ -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')
|
||||
})
|
||||
})
|
||||
}
|
6
test/integration/production/next.config.js
Normal file
6
test/integration/production/next.config.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
onDemandEntries: {
|
||||
// Make sure entries are not getting disposed.
|
||||
maxInactiveAge: 1000 * 60 * 60
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue