Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
133 lines
4.7 KiB
TypeScript
133 lines
4.7 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
for (const type of ['with-mdx-rs', 'without-mdx-rs']) {
|
|
describe(`mdx ${type}`, () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
dependencies: {
|
|
'@next/mdx': 'canary',
|
|
'@mdx-js/loader': '^2.2.1',
|
|
'@mdx-js/react': '^2.2.1',
|
|
'recma-export-filepath': '1.2.0',
|
|
'rehype-katex': '7.0.1',
|
|
'rehype-slug': '6.0.0',
|
|
'remark-gfm': '4.0.1',
|
|
'remark-toc': '9.0.0',
|
|
},
|
|
env: {
|
|
WITH_MDX_RS: type === 'with-mdx-rs' ? 'true' : 'false',
|
|
},
|
|
})
|
|
|
|
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 work in initial html with mdx import', async () => {
|
|
const $ = await next.render$('/import')
|
|
expect($('h1').text()).toBe('This is a title')
|
|
expect($('p').text()).toBe('This is a paragraph')
|
|
})
|
|
|
|
it('should work using browser with mdx import', async () => {
|
|
const browser = await next.browser('/import')
|
|
expect(await browser.elementByCss('h1').text()).toBe('This is a title')
|
|
expect(await browser.elementByCss('p').text()).toBe(
|
|
'This is a paragraph'
|
|
)
|
|
})
|
|
|
|
it('should allow overriding components', async () => {
|
|
const browser = await next.browser('/')
|
|
expect(await browser.elementByCss('h1').getComputedCss('color')).toBe(
|
|
'rgb(255, 0, 0)'
|
|
)
|
|
})
|
|
|
|
it('should allow importing client components', async () => {
|
|
const $ = await next.render$('/')
|
|
expect($('h2').text()).toBe('This is a client component')
|
|
})
|
|
|
|
it('should work with next/image', async () => {
|
|
const $ = await next.render$('/image')
|
|
expect($('img').attr('src')).toBe(
|
|
`/_next/image?url=%2Ftest.jpg&w=384&q=75${next.getDeploymentIdQuery(true)}`
|
|
)
|
|
})
|
|
|
|
if (type === 'without-mdx-rs') {
|
|
it('should run recma plugins', async () => {
|
|
const $ = await next.render$('/recma-plugin')
|
|
const html = $('html').html()
|
|
expect(html.includes('recma-plugin/page.mdx')).toBe(true)
|
|
expect($('#recma-plugin').text()).toBe('Recma plugin')
|
|
})
|
|
|
|
it('should run rehype plugins', async () => {
|
|
const $ = await next.render$('/rehype-plugin')
|
|
const html = $('html').html()
|
|
expect(html.includes('<mi>C</mi>')).toBe(true)
|
|
expect(html.includes('<mi>L</mi>')).toBe(true)
|
|
expect($('#rehype-plugin').text()).toBe('Rehype plugin')
|
|
})
|
|
|
|
it('should run remark plugins', async () => {
|
|
const $ = await next.render$('/remark-plugin')
|
|
const html = $('html').html()
|
|
expect(html.includes('The Table')).toBe(true)
|
|
expect($('a[href="#todo-list"]').text()).toBe('Todo List')
|
|
|
|
expect($('input[type="checkbox"]').length).toBe(2)
|
|
expect($('input[type="checkbox"][checked]').length).toBe(1)
|
|
})
|
|
}
|
|
})
|
|
|
|
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!')
|
|
})
|
|
|
|
// Recommended for tests that need a full browser
|
|
it('should work using browser', async () => {
|
|
const browser = await next.browser('/pages')
|
|
expect(await browser.elementByCss('h1').text()).toBe('Hello World')
|
|
expect(await browser.elementByCss('p').text()).toBe('This is MDX!')
|
|
})
|
|
|
|
it('should work in initial html with mdx import', async () => {
|
|
const $ = await next.render$('/pages/import')
|
|
expect($('h1').text()).toBe('This is a title')
|
|
expect($('p').text()).toBe('This is a paragraph')
|
|
})
|
|
|
|
it('should work using browser with mdx import', async () => {
|
|
const browser = await next.browser('/pages/import')
|
|
expect(await browser.elementByCss('h1').text()).toBe('This is a title')
|
|
expect(await browser.elementByCss('p').text()).toBe(
|
|
'This is a paragraph'
|
|
)
|
|
})
|
|
|
|
it('should allow overriding components', async () => {
|
|
const browser = await next.browser('/pages')
|
|
expect(await browser.elementByCss('h1').getComputedCss('color')).toBe(
|
|
'rgb(255, 0, 0)'
|
|
)
|
|
})
|
|
})
|
|
})
|
|
}
|