Unverified Commit 4f1be5d9 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

test(next-dev): migrate styled-jsx integration test (#55079)




### What?

There are tests under `next-dev-tests` which used native binary to run tests for Turbopack. This should belong to next.js integration tests, and also indeed there are overlaps.

As a first step, PR removes duplicated styled-jsx test and mark existing test under turbopack test filter as enabled.


Closes WEB-1510
parent cc34ea52
import React from 'react'
import TestRenderer from 'react-test-renderer'
describe('styled-jsx', () => {
it('compiles away <style jsx>', () => {
const test = TestRenderer.create(
<>
<span>This should be color: red</span>
<style jsx>{`
span {
color: red;
}
`}</style>
</>
)
expect(test.toJSON()).toMatchObject({
children: ['This should be color: red'],
props: {
className: /jsx\-[0-9a-f]+/,
},
type: 'span',
})
})
})
...@@ -186,6 +186,15 @@ async function startWatcher(opts: SetupOpts) { ...@@ -186,6 +186,15 @@ async function startWatcher(opts: SetupOpts) {
const { jsConfig } = await loadJsConfig(dir, opts.nextConfig) const { jsConfig } = await loadJsConfig(dir, opts.nextConfig)
// For the debugging purpose, check if createNext or equivalent next instance setup in test cases
// works correctly. Normally `run-test` hides output so only will be visible when `--debug` flag is used.
if (process.env.TURBOPACK && process.env.NEXT_TEST_MODE) {
require('console').log('Creating turbopack project', {
dir,
testMode: process.env.NEXT_TEST_MODE,
})
}
const project = await bindings.turbo.createProject({ const project = await bindings.turbo.createProject({
projectPath: dir, projectPath: dir,
rootPath: opts.nextConfig.experimental.outputFileTracingRoot || dir, rootPath: opts.nextConfig.experimental.outputFileTracingRoot || dir,
......
import path from 'path' import path from 'path'
import { createNext, FileRef } from 'e2e-utils' import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils' import { renderViaHTTP, shouldRunTurboDevTest } from 'next-test-utils'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
const appDir = path.join(__dirname, 'app') const appDir = path.join(__dirname, 'app')
...@@ -11,6 +11,8 @@ function runTest() { ...@@ -11,6 +11,8 @@ function runTest() {
let next: NextInstance let next: NextInstance
beforeAll(async () => { beforeAll(async () => {
const devCommand = shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'
next = await createNext({ next = await createNext({
files: { files: {
node_modules_bak: new FileRef(path.join(appDir, 'node_modules_bak')), node_modules_bak: new FileRef(path.join(appDir, 'node_modules_bak')),
...@@ -21,7 +23,7 @@ function runTest() { ...@@ -21,7 +23,7 @@ function runTest() {
scripts: { scripts: {
setup: `cp -r ./node_modules_bak/my-comps ./node_modules;`, setup: `cp -r ./node_modules_bak/my-comps ./node_modules;`,
build: `yarn setup && next build`, build: `yarn setup && next build`,
dev: `yarn setup && next dev`, dev: `yarn setup && next ${devCommand}`,
start: 'next start', start: 'next start',
}, },
}, },
......
...@@ -21,6 +21,7 @@ const enabledTests = [ ...@@ -21,6 +21,7 @@ const enabledTests = [
'test/e2e/type-module-interop/index.test.ts', 'test/e2e/type-module-interop/index.test.ts',
'test/e2e/undici-fetch/index.test.ts', 'test/e2e/undici-fetch/index.test.ts',
'test/integration/bigint/test/index.test.js', 'test/integration/bigint/test/index.test.js',
'test/e2e/styled-jsx/index.test.ts',
// TODO: re-enable once the logging is aligned // TODO: re-enable once the logging is aligned
// 'test/integration/middleware-basic/test/index.test.js', // 'test/integration/middleware-basic/test/index.test.js',
] ]
......
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