Files
vercel__next.js/test/development/plugin-mdx-rs/plugin-mdx-rs.test.ts
Sebastian "Sebbie" Silbermann 662b0355eb [test] Resolve workspace:* packages to the version under test (#98330)
Test fixtures that depend on monorepo packages (for example
`@next/third-parties` and `@next/mdx`) declared them at the `canary`
dist-tag, which installs the published npm canary instead of the build
under test. In deploy tests this also broke the remote install entirely:
the published canary's `peerDependencies` ranges (for example
`^16.0.0-beta.0`) reject the prerelease preview versions that
`NEXT_TEST_VERSION` installs for `next` (for example
`16.4.0-preview-<sha>-<date>`), so `npm install` failed with ERESOLVE.

Test dependencies can now be declared as `workspace:*`, which resolves
to the build from the current checkout in every test mode:

- dev/start: the locally packed tarball from `pack-for-isolated-tests`,
with a descriptive error when the package has no pack task or is not
part of the repository.
- deploy: the preview tarball of the tested commit when
`NEXT_TEST_VERSION` points at a preview build (preview tarballs already
rewrite their monorepo peer dependencies to the same preview URLs, so
peer resolution succeeds), falling back to the version in the worktree
otherwise. Private packages without published preview tarballs fail with
a descriptive error.

All existing tests that used `canary` for monorepo packages are migrated
to `workspace:*`.
2026-09-08 18:17:29 +02:00

61 lines
1.5 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('MDX-rs Plugin support', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
'@next/mdx': 'workspace:*',
'@mdx-js/loader': '*',
'@mdx-js/react': '*',
},
})
it('should render an MDX page correctly', async () => {
expect(await next.render('/')).toMatch(/Hello MDX/)
})
it('should render an MDX page with component correctly', async () => {
expect(await next.render('/button')).toMatch(/Look, a button!/)
})
it('should render an MDX page with globally provided components (from `mdx-components.js`) correctly', async () => {
expect(await next.render('/provider')).toMatch(/Marker was rendered!/)
})
})
describe('MDX-rs Plugin support with mdx transform options', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
'@next/mdx': 'workspace:*',
'@mdx-js/loader': '*',
'@mdx-js/react': '*',
},
skipStart: true,
})
beforeAll(async () => {
await next.patchFile(
'next.config.js',
`
const withMDX = require('@next/mdx')({
extension: /\\.mdx?$/,
})
module.exports = withMDX({
pageExtensions: ['js', 'jsx', 'mdx'],
experimental: {
mdxRs: {
mdxType: 'gfm'
},
},
})
`
)
await next.start()
})
it('should render an MDX page correctly', async () => {
expect(await next.render('/gfm')).toMatch(/<table>\n<thead>\n<tr>\n<th>foo/)
})
})