Files
vercel__next.js/test/development/basic/define-class-fields/define-class-fields.test.ts
Benjamin Woodruff 337a40c672 [ci] Pin typescript version in tests (#95619)
Typescript 7 came out, which is breaking a lot of our e2e tests.
2026-07-08 14:12:48 -07:00

55 lines
1.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { join } from 'path'
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
describe('useDefineForClassFields SWC option', () => {
const { next } = nextTestSetup({
files: join(__dirname, 'fixture'),
dependencies: {
mobx: '6.3.7',
'@types/react': 'latest',
'mobx-react': '7.2.1',
},
})
it('tsx should compile with useDefineForClassFields enabled', async () => {
const browser = await next.browser('/')
await browser.elementByCss('#action').click()
await check(
() => browser.elementByCss('#name').text(),
/this is my name: next/
)
})
it("Initializes resident to undefined after the call to 'super()' when with useDefineForClassFields enabled", async () => {
const browser = await next.browser('/animal')
expect(await browser.elementByCss('#dog').text()).toBe('undefined')
expect(await browser.elementByCss('#dogDecl').text()).toBe('dog')
})
async function matchLogs$(browser) {
let data_foundLog = false
let name_foundLog = false
const browserLogs = await browser.log()
browserLogs.forEach((log) => {
if (log.message.includes('data changed')) {
data_foundLog = true
}
if (log.message.includes('name changed')) {
name_foundLog = true
}
})
return [data_foundLog, name_foundLog]
}
it('set accessors from base classes wont get triggered with useDefineForClassFields enabled', async () => {
const browser = await next.browser('/derived')
await matchLogs$(browser).then(([data_foundLog, name_foundLog]) => {
expect(data_foundLog).toBe(true)
expect(name_foundLog).toBe(false)
})
})
})