rsnext/test/e2e/styled-jsx/index.test.ts
JJ Kasper 070239e666
Revert "Merge e2e test node_modules (#40926)" (#40974)
This reverts commit b508fef218.

Fixes: https://github.com/vercel/next.js/actions/runs/3139454323/jobs/5100342131

We aren't able to modify the filesystem for E2E deployments so this reverts the change introduced in the above PR to ensure deployment tests are able to run correctly with custom `node_modules`.
2022-09-28 08:08:46 +00:00

68 lines
2.1 KiB
TypeScript

import path from 'path'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
import webdriver from 'next-webdriver'
const appDir = path.join(__dirname, 'app')
function runTest() {
describe(`styled-jsx`, () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
node_modules_bak: new FileRef(path.join(appDir, 'node_modules_bak')),
pages: new FileRef(path.join(appDir, 'pages')),
'.npmrc': new FileRef(path.join(appDir, '.npmrc')),
},
packageJson: {
scripts: {
setup: `cp -r ./node_modules_bak/my-comps ./node_modules;`,
build: `yarn setup && next build`,
dev: `yarn setup && next dev`,
start: 'next start',
},
},
dependencies: {
'styled-jsx': '5.0.0', // styled-jsx on user side
},
startCommand: 'yarn ' + ((global as any).isNextDev ? 'dev' : 'start'),
buildCommand: `yarn build`,
})
})
afterAll(() => next.destroy())
it('should contain styled-jsx styles during SSR', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toMatch(/color:.*?red/)
expect(html).toMatch(/color:.*?cyan/)
})
it('should render styles during CSR', async () => {
const browser = await webdriver(next.url, '/')
const color = await browser.eval(
`getComputedStyle(document.querySelector('button')).color`
)
expect(color).toMatch('0, 255, 255')
})
it('should render styles during CSR (AMP)', async () => {
const browser = await webdriver(next.url, '/amp')
const color = await browser.eval(
`getComputedStyle(document.querySelector('button')).color`
)
expect(color).toMatch('0, 255, 255')
})
it('should render styles during SSR (AMP)', async () => {
const html = await renderViaHTTP(next.url, '/amp')
expect(html).toMatch(/color:.*?cyan/)
})
})
}
runTest()