`
// and silently dropped by React.
test('non-static testID with template literal is rewritten to data-testid', async () => {
const output = await extractForWeb(
`
import { View } from '@tamagui/core'
export function Test({ x }: { x: string }) {
return
}
`,
{
options: {
platform: 'web',
components: ['@tamagui/core'],
},
}
)
// should be rewritten to data-testid (not raw testID) and only emitted once.
expect(output?.js).toContain('data-testid={`a-${x}`}')
expect(output?.js?.match(/data-testid=/g)?.length).toBe(1)
expect(output?.js?.match(/\btestID=/g) ?? []).toHaveLength(0)
})
test('onLayout keeps the runtime component, since only it measures on web', async () => {
const output = await extractForWeb(
`
import { View } from '@tamagui/core'
export function Test(props) {
return
}
`,
{
options: {
platform: 'web',
components: ['@tamagui/core'],
},
}
)
expect(output?.js).toContain('onLayout')
expect(output?.js).not.toMatch(/
]*onLayout/)
})