mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What? Provide a fallback for the `mdx-components` file. ### Why? Given a user uses the Next.js app directory, and doesn’t have an `mdx-components` file; 1. If the user has `@mdx-js/react` installed, Next.js shows a cryptic error message, stating only client components may use React context. 2. If the user doesn’t have `@mdx-js/react` installed, Next.js shows a cryptic error message, stating `next-mdx-import-source-file` could not be resolved. ### How? This fixes 2 by providing a fallback. I suggest fixing 1, by completely removing all references to `@mdx-js/react` from the project. --------- Co-authored-by: JJ Kasper <[email protected]>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe(`mdx`, () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
dependencies: {
|
|
'@next/mdx': 'canary',
|
|
'@mdx-js/loader': '^2.2.1',
|
|
},
|
|
})
|
|
|
|
describe('app directory', () => {
|
|
it('should work in initial html', async () => {
|
|
const $ = await next.render$('/')
|
|
expect($('h1').text()).toBe('Hello World')
|
|
expect($('p').text()).toBe('This is MDX!')
|
|
})
|
|
|
|
it('should work using browser', async () => {
|
|
const browser = await next.browser('/')
|
|
expect(await browser.elementByCss('h1').text()).toBe('Hello World')
|
|
expect(await browser.elementByCss('p').text()).toBe('This is MDX!')
|
|
})
|
|
|
|
it('should allow importing client components', async () => {
|
|
const $ = await next.render$('/')
|
|
expect($('h2').text()).toBe('This is a client component')
|
|
})
|
|
})
|
|
|
|
describe('pages directory', () => {
|
|
it('should work in initial html', async () => {
|
|
const $ = await next.render$('/pages')
|
|
expect($('h1').text()).toBe('Hello World')
|
|
expect($('p').text()).toBe('This is MDX!')
|
|
})
|
|
})
|
|
})
|