1
0
Fork 0
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:
Tim Neutkens 2018-02-05 17:18:31 +01:00 committed by Arunoda Susiripala
parent 70295f2e87
commit ed122934af
13 changed files with 757 additions and 10 deletions

View file

@ -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",

View file

@ -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'),

View file

@ -0,0 +1,6 @@
module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
}
}

View file

@ -0,0 +1 @@
!node_modules

View file

@ -0,0 +1,3 @@
.helloWorld {
color: red;
}

View file

@ -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>

View 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
})

View file

@ -0,0 +1,3 @@
.frameworkClass {
font-size: 100px;
}

View file

@ -0,0 +1,3 @@
import HelloWebpackCSS from '../components/hello-webpack-css'
export default () => <HelloWebpackCSS />

View 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))
})

View 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')
})
})
}

View file

@ -0,0 +1,6 @@
module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
}
}

678
yarn.lock

File diff suppressed because it is too large Load diff