2024-02-15 00:42:35 +01:00
|
|
|
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
|
|
|
|
describe('styled-jsx', () => {
|
|
|
|
const { next, skipped } = nextTestSetup({
|
|
|
|
files: __dirname,
|
|
|
|
skipDeployment: true,
|
|
|
|
dependencies: {
|
|
|
|
'styled-jsx': '5.0.0', // styled-jsx on user side
|
|
|
|
},
|
|
|
|
})
|
2024-04-25 20:06:12 +02:00
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
if (skipped) {
|
|
|
|
return
|
2024-02-15 00:42:35 +01:00
|
|
|
}
|
2024-04-25 20:06:12 +02:00
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
it('should contain styled-jsx styles during SSR', async () => {
|
2024-02-15 00:42:35 +01:00
|
|
|
const html = await next.render('/')
|
2022-08-09 03:27:42 +02:00
|
|
|
expect(html).toMatch(/color:.*?red/)
|
|
|
|
expect(html).toMatch(/color:.*?cyan/)
|
2024-04-25 20:06:12 +02:00
|
|
|
})
|
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
it('should render styles during CSR', async () => {
|
2024-02-15 00:42:35 +01:00
|
|
|
const browser = await next.browser('/')
|
2022-08-09 03:27:42 +02:00
|
|
|
const color = await browser.eval(
|
|
|
|
`getComputedStyle(document.querySelector('button')).color`
|
2024-02-15 00:42:35 +01:00
|
|
|
)
|
2024-04-25 20:06:12 +02:00
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
expect(color).toMatch('0, 255, 255')
|
2024-04-25 20:06:12 +02:00
|
|
|
})
|
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
it('should render styles during CSR (AMP)', async () => {
|
2024-02-15 00:42:35 +01:00
|
|
|
const browser = await next.browser('/amp')
|
2022-08-09 03:27:42 +02:00
|
|
|
const color = await browser.eval(
|
|
|
|
`getComputedStyle(document.querySelector('button')).color`
|
2024-04-25 20:06:12 +02:00
|
|
|
)
|
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
expect(color).toMatch('0, 255, 255')
|
2024-04-25 20:06:12 +02:00
|
|
|
})
|
|
|
|
|
2022-08-09 03:27:42 +02:00
|
|
|
it('should render styles during SSR (AMP)', async () => {
|
2024-02-15 00:42:35 +01:00
|
|
|
const html = await next.render('/amp')
|
2022-08-09 03:27:42 +02:00
|
|
|
expect(html).toMatch(/color:.*?cyan/)
|
2024-04-25 20:06:12 +02:00
|
|
|
})
|
|
|
|
})
|