Unverified Commit 25ee71f3 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Add CSS Resolve Test (#9724)

parent 529ab0c0
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
"node-notifier": "5.4.0", "node-notifier": "5.4.0",
"node-sass": "4.12.0", "node-sass": "4.12.0",
"npm-run-all": "4.1.5", "npm-run-all": "4.1.5",
"nprogress": "0.2.0",
"pixrem": "5.0.0", "pixrem": "5.0.0",
"postcss-pseudoelements": "5.0.0", "postcss-pseudoelements": "5.0.0",
"postcss-short-size": "4.0.0", "postcss-short-size": "4.0.0",
......
import React from 'react'
import App from 'next/app'
import '../styles/global.css'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp
export default function Home() {
return <div className="red-text">This text should be red.</div>
}
import React from 'react'
import App from 'next/app'
import '../styles/global.css'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp
export default function Home() {
return <div className="red-text">This text should be red.</div>
}
...@@ -511,6 +511,44 @@ describe('CSS Support', () => { ...@@ -511,6 +511,44 @@ describe('CSS Support', () => {
}) })
}) })
describe('Good CSS Import from node_modules', () => {
const appDir = join(fixturesDir, 'npm-import')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should build successfully', async () => {
await nextBuild(appDir)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter(f => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(/nprogress/)
})
})
describe('Bad CSS Import from node_modules', () => {
const appDir = join(fixturesDir, 'npm-import-bad')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail the build', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/)
expect(stderr).toMatch(/Build error occurred/)
})
})
describe('Ordering with styled-jsx (dev)', () => { describe('Ordering with styled-jsx (dev)', () => {
const appDir = join(fixturesDir, 'with-styled-jsx') const appDir = join(fixturesDir, 'with-styled-jsx')
......
...@@ -10989,6 +10989,11 @@ npm-run-path@^3.0.0: ...@@ -10989,6 +10989,11 @@ npm-run-path@^3.0.0:
gauge "~2.7.3" gauge "~2.7.3"
set-blocking "~2.0.0" set-blocking "~2.0.0"
nprogress@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1"
integrity sha1-y480xTIT2JVyP8urkH6UIq28r7E=
nth-check@^1.0.2, nth-check@~1.0.1: nth-check@^1.0.2, nth-check@~1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c"
......
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