Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c4cf641c
Unverified
Commit
c4cf641c
authored
Jan 03, 2020
by
Joe Haddad
Committed by
GitHub
Jan 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test 3rd Party CSS Modules (#9924)
parent
ef6df482
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
0 deletions
+69
-0
index.js
.../integration/css-fixtures/3rd-party-module/pages/index.js
+5
-0
index.module.css
...tion/css-fixtures/3rd-party-module/pages/index.module.css
+17
-0
index.test.js
test/integration/css-modules/test/index.test.js
+47
-0
No files found.
test/integration/css-fixtures/3rd-party-module/pages/index.js
0 → 100644
View file @
c4cf641c
import
{
foo
}
from
'./index.module.css'
export
default
function
Home
()
{
return
<
div
id
=
"verify-div"
className
=
{
foo
}
/
>
}
test/integration/css-fixtures/3rd-party-module/pages/index.module.css
0 → 100644
View file @
c4cf641c
.foo
{
position
:
relative
;
}
.foo
:global
(
.bar
),
.foo
:global
(
.baz
)
{
height
:
100%
;
overflow
:
hidden
;
}
.foo
:global
(
.lol
)
{
width
:
80%
;
}
.foo
>
:global
(
.lel
)
{
width
:
80%
;
}
test/integration/css-modules/test/index.test.js
View file @
c4cf641c
...
...
@@ -65,6 +65,53 @@ describe('Basic CSS Module Support', () => {
})
})
describe
(
'3rd Party CSS Module Support'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'3rd-party-module'
)
let
appPort
let
app
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
afterAll
(
async
()
=>
{
await
killApp
(
app
)
})
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
()).
toMatchInlineSnapshot
(
`".index_foo__29BAH{position:relative}.index_foo__29BAH .bar,.index_foo__29BAH .baz{height:100%;overflow:hidden}.index_foo__29BAH .lol,.index_foo__29BAH>.lel{width:80%}"`
)
})
it
(
`should've injected the CSS on server render`
,
async
()
=>
{
const
content
=
await
renderViaHTTP
(
appPort
,
'/'
)
const
$
=
cheerio
.
load
(
content
)
const
cssPreload
=
$
(
'link[rel="preload"][as="style"]'
)
expect
(
cssPreload
.
length
).
toBe
(
1
)
expect
(
cssPreload
.
attr
(
'href'
)).
toMatch
(
/^
\/
_next
\/
static
\/
css
\/
.*
\.
css$/
)
const
cssSheet
=
$
(
'link[rel="stylesheet"]'
)
expect
(
cssSheet
.
length
).
toBe
(
1
)
expect
(
cssSheet
.
attr
(
'href'
)).
toMatch
(
/^
\/
_next
\/
static
\/
css
\/
.*
\.
css$/
)
expect
(
$
(
'#verify-div'
).
attr
(
'class'
)).
toMatchInlineSnapshot
(
`"index_foo__29BAH"`
)
})
})
describe
(
'Has CSS Module in computed styles in Development'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'dev-module'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment