Unverified Commit 50b9966b authored by Joost's avatar Joost Committed by GitHub

Add sassOption `implementation` to support sass-embedded (#64577)

## What?
This PR adds an option to use `sass-embedded`.

## Why?
For large projects sass-embedded improves SCSS compilation time by over
50%.
See also https://github.com/vercel/next.js/discussions/36160

## How?
Added a sassOption `implementation` to configure the sass-loader which
Sass implementation to use.
See also https://www.npmjs.com/package/sass-loader#implementation

I think this a similar approach to what is done for `additionalData`.

## Additional notes
In order to support `sass-embedded`, `sass-loader` is upgraded to
12.6.0.

---------
Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
parent d02dfc6e
......@@ -38,6 +38,7 @@ pub async fn maybe_add_sass_loader(
loader: "next/dist/compiled/sass-loader".into(),
options: take(
serde_json::json!({
"implementation": sass_options.get("implementation"),
"sourceMap": true,
"sassOptions": sass_options,
"additionalData": additional_data
......
......@@ -292,7 +292,7 @@
"react-is": "19.0.0-canary-94eed63c49-20240425",
"react-refresh": "0.12.0",
"regenerator-runtime": "0.13.4",
"sass-loader": "12.4.0",
"sass-loader": "12.6.0",
"schema-utils2": "npm:schema-utils@2.7.1",
"schema-utils3": "npm:schema-utils@3.0.0",
"semver": "7.3.2",
......
......@@ -150,6 +150,7 @@ export const css = curry(async function css(
const {
prependData: sassPrependData,
additionalData: sassAdditionalData,
implementation: sassImplementation,
...sassOptions
} = ctx.sassOptions
......@@ -167,6 +168,7 @@ export const css = curry(async function css(
{
loader: require.resolve('next/dist/compiled/sass-loader'),
options: {
implementation: sassImplementation,
// Source maps are required so that `resolve-url-loader` can locate
// files original to their source directory.
sourceMap: true,
......
......@@ -1366,8 +1366,8 @@ importers:
specifier: 0.13.4
version: 0.13.4
sass-loader:
specifier: 12.4.0
version: 12.4.0(sass@1.54.0)(webpack@5.90.0)
specifier: 12.6.0
version: 12.6.0(sass@1.54.0)(webpack@5.90.0)
schema-utils2:
specifier: npm:schema-utils@2.7.1
version: /schema-utils@2.7.1
......@@ -2201,7 +2201,6 @@ packages:
/@babel/plugin-proposal-dynamic-import@7.16.7(@babel/core@7.22.5):
resolution: {integrity: sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.
peerDependencies:
'@babel/core': 7.22.5
dependencies:
......@@ -2212,7 +2211,6 @@ packages:
/@babel/plugin-proposal-export-namespace-from@7.16.7(@babel/core@7.22.5):
resolution: {integrity: sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
peerDependencies:
'@babel/core': 7.22.5
dependencies:
......@@ -2235,7 +2233,6 @@ packages:
/@babel/plugin-proposal-logical-assignment-operators@7.16.7(@babel/core@7.22.5):
resolution: {integrity: sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
peerDependencies:
'@babel/core': 7.22.5
dependencies:
......@@ -2258,7 +2255,6 @@ packages:
/@babel/plugin-proposal-numeric-separator@7.16.7(@babel/core@7.22.5):
resolution: {integrity: sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
peerDependencies:
'@babel/core': 7.22.5
dependencies:
......@@ -2308,7 +2304,6 @@ packages:
/@babel/plugin-proposal-private-methods@7.16.11(@babel/core@7.22.5):
resolution: {integrity: sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
peerDependencies:
'@babel/core': 7.22.5
dependencies:
......@@ -23189,13 +23184,14 @@ packages:
/safer-buffer@2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
/sass-loader@12.4.0(sass@1.54.0)(webpack@5.90.0):
resolution: {integrity: sha512-7xN+8khDIzym1oL9XyS6zP6Ges+Bo2B2xbPrjdMHEYyV3AQYhd/wXeru++3ODHF0zMjYmVadblSKrPrjEkL8mg==}
/sass-loader@12.6.0(sass@1.54.0)(webpack@5.90.0):
resolution: {integrity: sha512-oLTaH0YCtX4cfnJZxKSLAyglED0naiYfNG1iXfU5w1LNZ+ukoA5DtyDIN5zmKVZwYNJP4KRc5Y3hkWga+7tYfA==}
engines: {node: '>= 12.13.0'}
peerDependencies:
fibers: '>= 3.1.0'
node-sass: ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
sass: ^1.3.0
sass-embedded: '*'
webpack: 5.90.0
peerDependenciesMeta:
fibers:
......@@ -23204,6 +23200,8 @@ packages:
optional: true
sass:
optional: true
sass-embedded:
optional: true
dependencies:
klona: 2.0.4
neo-async: 2.6.2
......
......@@ -3,42 +3,54 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('3rd Party CSS Module Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'3rd Party CSS Module Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
// Bar
expect(
await browser
.elementByCss('#verify-div .bar')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
it('should render the module', async () => {
const browser = await next.browser('/')
// Bar
expect(
await browser
.elementByCss('#verify-div .bar')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
// Baz
expect(
await browser
.elementByCss('#verify-div .baz')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
// Baz
expect(
await browser
.elementByCss('#verify-div .baz')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
// Lol
expect(
await browser
.elementByCss('#verify-div .lol')
.getComputedCss('background-color')
).toBe(colorToRgb('red'))
// Lol
expect(
await browser
.elementByCss('#verify-div .lol')
.getComputedCss('background-color')
).toBe(colorToRgb('red'))
// Lel
expect(
await browser
.elementByCss('#verify-div .lel')
.getComputedCss('background-color')
).toBe(colorToRgb('green'))
})
})
// Lel
expect(
await browser
.elementByCss('#verify-div .lel')
.getComputedCss('background-color')
).toBe(colorToRgb('green'))
})
}
)
......@@ -3,18 +3,37 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic Module Additional Data Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
additionalData: `
$var: red;
`,
}
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Additional Data Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
module.exports = {
sassOptions: {
additionalData: `
$var: red;
`,
},
}
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic Module Include Paths Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
includePaths: ['./styles'],
}
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Include Paths Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
const path = require('path')
module.exports = {
sassOptions: {
includePaths: [path.join(__dirname, 'styles')],
},
}
......@@ -3,18 +3,37 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic Module Prepend Data Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
const sassOptions = {
prependData: `
$var: red;
`,
}
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: { sassOptions } },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
...sassOptions,
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Module Prepend Data Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
module.exports = {
sassOptions: {
prependData: `
$var: red;
`,
},
}
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic SCSS Module Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic SCSS Module Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Catch-all Route CSS Module Usage', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Catch-all Route CSS Module Usage ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/post')
expect(
await browser.elementByCss('#my-div').getComputedCss('background-color')
).toBe(colorToRgb('red'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/post')
expect(
await browser.elementByCss('#my-div').getComputedCss('background-color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -4,15 +4,29 @@ import { nextTestSetup } from 'e2e-utils'
import { readdir, readFile } from 'fs-extra'
import { join } from 'path'
describe('SCSS Support', () => {
const nextConfig = {
productionBrowserSourceMaps: true,
}
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
...nextConfig,
sassOptions: {
implementation: 'sass-embedded',
},
},
},
])('SCSS Support ($dependencies)', ({ dependencies, nextConfig }) => {
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
// This test is skipped because it is reading files in the `.next` file which
// isn't available/necessary in a deployment environment.
skipDeployment: true,
dependencies: {
sass: '1.54.0',
},
dependencies,
nextConfig,
})
if (skipped) return // TODO: Figure out this test for dev and Turbopack
......
module.exports = {
productionBrowserSourceMaps: true,
}
......@@ -3,23 +3,35 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('CSS Module Composes Usage (Basic)', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'CSS Module Composes Usage (Basic) ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-yellow').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser
.elementByCss('#verify-yellow')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-yellow').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser
.elementByCss('#verify-yellow')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
}
)
......@@ -3,23 +3,35 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('CSS Module Composes Usage (External)', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'CSS Module Composes Usage (External) ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-yellow').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser
.elementByCss('#verify-yellow')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-yellow').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser
.elementByCss('#verify-yellow')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
}
)
......@@ -3,20 +3,32 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('SCSS Support loader handling Data Urls', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'SCSS Support loader handling Data Urls ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
const redText = await browser.elementByCss('.red-text')
expect(await redText.getComputedCss('color')).toBe(colorToRgb('red'))
expect(await redText.getComputedCss('background-image')).toMatch(
/url\("data:[^"]+"\)$/
)
})
})
it('should render the module', async () => {
const browser = await next.browser('/')
const redText = await browser.elementByCss('.red-text')
expect(await redText.getComputedCss('color')).toBe(colorToRgb('red'))
expect(await redText.getComputedCss('background-image')).toMatch(
/url\("data:[^"]+"\)$/
)
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Has CSS Module in computed styles in Development', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Has CSS Module in computed styles in Development ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should have CSS for page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should have CSS for page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,20 +3,32 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Dynamic Route CSS Module Usage', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
it('should apply styles correctly', async () => {
const browser = await next.browser('/post-1')
},
])(
'Dynamic Route CSS Module Usage ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should apply styles correctly', async () => {
const browser = await next.browser('/post-1')
const background = await browser
.elementByCss('#my-div')
.getComputedCss('background-color')
const background = await browser
.elementByCss('#my-div')
.getComputedCss('background-color')
expect(background).toMatch(colorToRgb('red'))
})
})
expect(background).toMatch(colorToRgb('red'))
})
}
)
......@@ -2,24 +2,36 @@
import { nextTestSetup } from 'e2e-utils'
describe('SCSS Support loader handling External imports', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
it(`should include font on the page`, async () => {
const browser = await next.browser('/')
const result = await browser.eval(async function () {
return document.fonts.ready.then((fonts) => {
const includedFonts = []
for (const font of fonts.values()) {
includedFonts.push(font.family)
}
return includedFonts
},
])(
'SCSS Support loader handling External imports ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it(`should include font on the page`, async () => {
const browser = await next.browser('/')
const result = await browser.eval(async function () {
return document.fonts.ready.then((fonts) => {
const includedFonts = []
for (const font of fonts.values()) {
includedFonts.push(font.family)
}
return includedFonts
})
})
expect(result).toInclude('Poppins')
})
expect(result).toInclude('Poppins')
})
})
}
)
......@@ -3,41 +3,53 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb, retry } from 'next-test-utils'
describe('Can hot reload CSS Module without losing state', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
;(isNextDev ? describe : describe.skip)('development only', () => {
it('should update CSS color without remounting <input>', async () => {
const browser = await next.browser('/')
const desiredText = 'hello world'
await browser.elementById('text-input').type(desiredText)
expect(await browser.elementById('text-input').getValue()).toBe(
desiredText
)
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
},
])(
'Can hot reload CSS Module without losing state ($dependencies)',
({ dependencies, nextConfig }) => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
;(isNextDev ? describe : describe.skip)('development only', () => {
it('should update CSS color without remounting <input>', async () => {
const browser = await next.browser('/')
await next.patchFile('pages/index.module.scss', (content) => {
return content.replace('$var: red', '$var: purple')
})
const desiredText = 'hello world'
await browser.elementById('text-input').type(desiredText)
expect(await browser.elementById('text-input').getValue()).toBe(
desiredText
)
await retry(async () => {
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('purple'))
})
).toBe(colorToRgb('red'))
await next.patchFile('pages/index.module.scss', (content) => {
return content.replace('$var: red', '$var: purple')
})
// ensure text remained
expect(await browser.elementById('text-input').getValue()).toBe(
desiredText
)
await retry(async () => {
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('purple'))
})
// ensure text remained
expect(await browser.elementById('text-input').getValue()).toBe(
desiredText
)
})
})
})
})
}
)
......@@ -3,17 +3,29 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('SCSS Support loader handling Preprocessor loader order', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
},
])(
'SCSS Support loader handling Preprocessor loader order ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the module', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('(SCSS) Multi Global Support (reversed)', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'(SCSS) Multi Global Support (reversed) ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-blue').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-blue').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
}
)
......@@ -3,12 +3,21 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Multi Global Support', () => {
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
},
])('Multi Global Support ($dependencies)', ({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
},
dependencies,
nextConfig,
})
it('should render the page', async () => {
......
......@@ -3,12 +3,21 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb, retry } from 'next-test-utils'
describe('SCSS Support', () => {
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
},
])('SCSS Support ($dependencies)', ({ dependencies, nextConfig }) => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
},
dependencies,
nextConfig,
})
describe('Has CSS in computed styles in Production', () => {
it('should have CSS for page', async () => {
......
......@@ -3,21 +3,33 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Nested @import() Global Support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Nested @import() Global Support ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
expect(
await browser.elementByCss('.blue-text').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
expect(
await browser.elementByCss('.blue-text').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
}
)
......@@ -3,27 +3,41 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Valid Nested CSS Module Usage from within node_modules', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Valid Nested CSS Module Usage from within node_modules ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#other2').getComputedCss('color')).toBe(
colorToRgb('red')
)
expect(await browser.elementByCss('#other3').getComputedCss('color')).toBe(
colorToRgb('black')
)
expect(
await browser.elementByCss('#subclass').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser.elementByCss('#subclass').getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#other2').getComputedCss('color')
).toBe(colorToRgb('red'))
expect(
await browser.elementByCss('#other3').getComputedCss('color')
).toBe(colorToRgb('black'))
expect(
await browser.elementByCss('#subclass').getComputedCss('color')
).toBe(colorToRgb('yellow'))
expect(
await browser
.elementByCss('#subclass')
.getComputedCss('background-color')
).toBe(colorToRgb('blue'))
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Valid CSS Module Usage from within node_modules', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Valid CSS Module Usage from within node_modules ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#nm-div').getComputedCss('color')).toBe(
colorToRgb('red')
)
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#nm-div').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,21 +3,33 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Good Nested CSS Import from node_modules', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Good Nested CSS Import from node_modules ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
expect(
await browser.elementByCss('.blue-text').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
expect(
await browser.elementByCss('.blue-text').getComputedCss('color')
).toBe(colorToRgb('blue'))
})
}
)
module.exports = {
experimental: {
turbo: {
resolveAlias: {
'/*': './*',
'~*': '*',
},
},
},
}
......@@ -2,21 +2,47 @@
import { nextTestSetup } from 'e2e-utils'
describe('Good CSS Import from node_modules with tilde', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
nprogress: '0.2.0',
const nextConfig = {
experimental: {
turbo: {
resolveAlias: {
'/*': './*',
'~*': '*',
},
},
})
},
}
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser
.elementByCss('#nprogress .bar')
.getComputedCss('background-color')
).toBe('rgb(34, 153, 221)')
})
})
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
...nextConfig,
sassOptions: {
implementation: 'sass-embedded',
},
},
},
])(
'Good CSS Import from node_modules with tilde ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
...dependencies,
nprogress: '0.2.0',
},
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser
.elementByCss('#nprogress .bar')
.getComputedCss('background-color')
).toBe('rgb(34, 153, 221)')
})
}
)
......@@ -2,21 +2,35 @@
import { nextTestSetup } from 'e2e-utils'
describe('Good CSS Import from node_modules', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
nprogress: '0.2.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Good CSS Import from node_modules ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
...dependencies,
nprogress: '0.2.0',
},
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser
.elementByCss('#nprogress .bar')
.getComputedCss('background-color')
).toBe('rgb(34, 153, 221)')
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser
.elementByCss('#nprogress .bar')
.getComputedCss('background-color')
).toBe('rgb(34, 153, 221)')
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Has CSS Module in computed styles in Production', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Has CSS Module in computed styles in Production ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('#verify-red').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic Global Support with src/ dir', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Global Support with src/ dir ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Basic Global Support scss', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Basic Global Support scss ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
})
}
)
......@@ -2,13 +2,22 @@
import { nextTestSetup } from 'e2e-utils'
describe('unused scss', () => {
describe('Body is not hidden when unused in Development', () => {
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
},
])('unused scss', ({ dependencies, nextConfig }) => {
describe('Body is not hidden when unused in Development ($dependencies)', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
},
dependencies,
nextConfig,
})
;(isNextDev ? describe : describe.skip)('development only', () => {
......@@ -25,9 +34,8 @@ describe('unused scss', () => {
describe('Body is not hidden when broken in Development', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
},
dependencies,
nextConfig,
})
;(isNextDev ? describe : describe.skip)('development only', () => {
......
......@@ -5,33 +5,45 @@ import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils'
// TODO: Skipped as this test should set up the server to handle assetPrefix which it currently does not do.
describe.skip('SCSS Support loader handling', () => {
describe('CSS URL via `file-loader` and asset prefix (1)', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'CSS URL via `file-loader` and asset prefix (1) ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/foo\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/foo\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/foo\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/foo\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const urls = getUrlFromBackgroundImage(background)
const urls = getUrlFromBackgroundImage(background)
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
})
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
}
)
})
......@@ -5,33 +5,45 @@ import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils'
// TODO: Skipped as this test should set up the server to handle assetPrefix which it currently does not do.
describe.skip('SCSS Support loader handling', () => {
describe('CSS URL via `file-loader` and asset prefix (2)', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'CSS URL via `file-loader` and asset prefix (2) ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/foo\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/foo\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/foo\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/foo\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const urls = getUrlFromBackgroundImage(background)
const urls = getUrlFromBackgroundImage(background)
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
})
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
}
)
})
......@@ -4,33 +4,45 @@ import { nextTestSetup } from 'e2e-utils'
import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils'
describe('SCSS Support loader handling', () => {
describe('CSS URL via file-loader sass partial', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'CSS URL via file-loader sass partial ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/_next\/static\/media\/darka\..*\.svg"\), url\(".*\/_next\/static\/media\/darkb\..*\.svg"\)/
)
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/_next\/static\/media\/darka\..*\.svg"\), url\(".*\/_next\/static\/media\/darkb\..*\.svg"\)/
)
const urls = getUrlFromBackgroundImage(background)
const urls = getUrlFromBackgroundImage(background)
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
})
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
}
)
})
......@@ -3,34 +3,46 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb, getUrlFromBackgroundImage } from 'next-test-utils'
describe('SCSS Support loader handling', () => {
describe('CSS URL via `file-loader`', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
})
},
},
])(
'SCSS Support loader handling ($dependencies)',
({ dependencies, nextConfig }) => {
describe('CSS URL via `file-loader`', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
it('should render the page', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.red-text').getComputedCss('color')
).toBe(colorToRgb('red'))
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const background = await browser
.elementByCss('.red-text')
.getComputedCss('background-image')
expect(background).toMatch(
/url\(".*\/_next\/static\/media\/dark\..*\.svg"\), url\(".*\/_next\/static\/media\/dark2\..*\.svg"\)/
)
const urls = getUrlFromBackgroundImage(background)
const urls = getUrlFromBackgroundImage(background)
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
for (const url of urls) {
const response = await next.fetch(url)
expect(response.status).toBe(200)
}
})
})
})
})
}
)
......@@ -3,18 +3,30 @@
import { nextTestSetup } from 'e2e-utils'
import { colorToRgb } from 'next-test-utils'
describe('Ordering with styled-jsx', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
sass: '1.54.0',
describe.each([
{ dependencies: { sass: '1.54.0' }, nextConfig: undefined },
{
dependencies: { 'sass-embedded': '1.75.0' },
nextConfig: {
sassOptions: {
implementation: 'sass-embedded',
},
},
})
},
])(
'Ordering with styled-jsx ($dependencies)',
({ dependencies, nextConfig }) => {
const { next } = nextTestSetup({
files: __dirname,
dependencies,
nextConfig,
})
it('should have the correct color (css ordering)', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('.my-text').getComputedCss('color')).toBe(
colorToRgb('green')
)
})
})
it('should have the correct color (css ordering)', async () => {
const browser = await next.browser('/')
expect(
await browser.elementByCss('.my-text').getComputedCss('color')
).toBe(colorToRgb('green'))
})
}
)
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