Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 30, 2022
1 parent 1fb6a19 commit 81ce040
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
6 changes: 4 additions & 2 deletions packages/next/pages/_document.tsx
@@ -1,5 +1,8 @@
import React, { Component, ReactElement, ReactNode, useContext } from 'react'
import { OPTIMIZED_FONT_PROVIDERS } from '../shared/lib/constants'
import {
OPTIMIZED_FONT_PROVIDERS,
NEXT_BUILTIN_DOCUMENT,
} from '../shared/lib/constants'
import type {
DocumentContext,
DocumentInitialProps,
Expand Down Expand Up @@ -310,7 +313,6 @@ export default class Document<P = {}> extends Component<DocumentProps & P> {

// Add a special property to the built-in `Document` component so later we can
// identify if a user customized `Document` is used or not.
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'
const InternalFunctionDocument: DocumentType =
function InternalFunctionDocument() {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/render.tsx
Expand Up @@ -36,6 +36,7 @@ import {
UNSTABLE_REVALIDATE_RENAME_ERROR,
} from '../lib/constants'
import {
NEXT_BUILTIN_DOCUMENT,
SERVER_PROPS_ID,
STATIC_PROPS_ID,
STATIC_STATUS_PAGES,
Expand Down Expand Up @@ -81,7 +82,6 @@ import { FlushEffectsContext } from '../shared/lib/flush-effects'
import { interopDefault } from '../lib/interop-default'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { urlQueryToSearchParams } from '../shared/lib/router/utils/querystring'
import { NEXT_BUILTIN_DOCUMENT } from '../pages/_document'

let optimizeAmp: typeof import('./optimize-amp').default
let getFontDefinitionFromManifest: typeof import('./font-utils').getFontDefinitionFromManifest
Expand Down
1 change: 1 addition & 0 deletions packages/next/shared/lib/constants.ts
Expand Up @@ -25,6 +25,7 @@ export const CLIENT_PUBLIC_FILES_PATH = 'public'
export const CLIENT_STATIC_FILES_PATH = 'static'
export const CLIENT_STATIC_FILES_RUNTIME = 'runtime'
export const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__'
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'

// server/middleware-flight-manifest.js
export const MIDDLEWARE_FLIGHT_MANIFEST = 'middleware-flight-manifest'
Expand Down
18 changes: 2 additions & 16 deletions test/e2e/styled-jsx/index.test.ts
Expand Up @@ -14,21 +14,7 @@ function runTest(packageManager?: string) {
next = await createNext({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
// 'next.config.js': new FileRef(path.join(appDir, 'next.config.js')),
},

// files: {
// 'pages/index.js': `
// export default function Page() {
// return (
// <div>
// <style jsx>{'p { color: red; }'}</style>
// <p>hello world</p>
// </div>
// )
// }
// `,
// },
...(packageManager
? {
installCommand: `npx ${packageManager} install`,
Expand All @@ -41,8 +27,8 @@ function runTest(packageManager?: string) {
it('should contain styled-jsx styles in html', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
const body = $('body').text()
expect(body).toMatch(/color:(\s)*red/)
const isReact17 = process.env.NEXT_TEST_REACT_VERSION === '^17'
expect($(isReact17 ? 'head' : 'body').text()).toMatch(/color:(\s)*red/)
})
})
}
Expand Down

0 comments on commit 81ce040

Please sign in to comment.