Commit ed122934 authored by Tim Neutkens's avatar Tim Neutkens Committed by Arunoda Susiripala

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
parent 70295f2e
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
"@taskr/clear": "1.1.0", "@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0", "@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0", "@taskr/watch": "1.1.0",
"@zeit/next-css": "0.0.7",
"babel-eslint": "8.0.1", "babel-eslint": "8.0.1",
"babel-jest": "21.2.0", "babel-jest": "21.2.0",
"babel-plugin-istanbul": "4.1.5", "babel-plugin-istanbul": "4.1.5",
......
...@@ -35,6 +35,7 @@ describe('Basic Features', () => { ...@@ -35,6 +35,7 @@ describe('Basic Features', () => {
renderViaHTTP(context.appPort, '/link'), renderViaHTTP(context.appPort, '/link'),
renderViaHTTP(context.appPort, '/stateful'), renderViaHTTP(context.appPort, '/stateful'),
renderViaHTTP(context.appPort, '/stateless'), renderViaHTTP(context.appPort, '/stateless'),
renderViaHTTP(context.appPort, '/custom-extension'),
renderViaHTTP(context.appPort, '/styled-jsx'), renderViaHTTP(context.appPort, '/styled-jsx'),
renderViaHTTP(context.appPort, '/with-cdm'), renderViaHTTP(context.appPort, '/with-cdm'),
......
module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
}
}
!node_modules
\ No newline at end of file
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>
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
},
cssModules: true
})
.frameworkClass {
font-size: 100px;
}
\ No newline at end of file
import HelloWebpackCSS from '../components/hello-webpack-css'
export default () => <HelloWebpackCSS />
/* 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))
})
/* 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')
})
})
}
module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment