2022-05-02 22:52:46 +02:00
|
|
|
import path from 'path'
|
|
|
|
import { createNext, FileRef } from 'e2e-utils'
|
2022-04-30 22:25:05 +02:00
|
|
|
import { NextInstance } from 'test/lib/next-modes/base'
|
|
|
|
import { renderViaHTTP } from 'next-test-utils'
|
|
|
|
import cheerio from 'cheerio'
|
|
|
|
|
2022-05-02 22:52:46 +02:00
|
|
|
const appDir = path.join(__dirname, 'app')
|
|
|
|
|
2022-04-30 22:25:05 +02:00
|
|
|
function runTest(packageManager?: string) {
|
|
|
|
describe(`styled-jsx${packageManager ? ' ' + packageManager : ''}`, () => {
|
|
|
|
let next: NextInstance
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
next = await createNext({
|
|
|
|
files: {
|
2022-05-02 22:52:46 +02:00
|
|
|
pages: new FileRef(path.join(appDir, 'pages')),
|
2022-04-30 22:25:05 +02:00
|
|
|
},
|
|
|
|
...(packageManager
|
|
|
|
? {
|
|
|
|
installCommand: `npx ${packageManager} install`,
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
afterAll(() => next.destroy())
|
|
|
|
|
|
|
|
it('should contain styled-jsx styles in html', async () => {
|
|
|
|
const html = await renderViaHTTP(next.url, '/')
|
|
|
|
const $ = cheerio.load(html)
|
2022-05-02 22:52:46 +02:00
|
|
|
expect($('html').text()).toMatch(/color:(\s)*red/)
|
2022-04-30 22:25:05 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
runTest()
|
|
|
|
runTest('pnpm')
|