Files
orca/config/scripts/check-mobile-shared-dependency-versions.test.mjs
T
Neil cc2b6fe6a2 build(mobile): move to TypeScript 7 and Vitest 5, typecheck through the root tsrs runner (#33419)
- Bump mobile typescript to ^7.0.2 and vitest to 5.0.5; keep TypeScript 6 as typescript-api
  for the test-support code that walks the AST, mirroring the root.
- Patch Expo CLI's tsconfig reader to fall back to typescript-api: TypeScript 7 has no
  compiler API, and Metro otherwise crashes reading tsconfig paths.
- Register mobile/tsconfig.json and mobile/tsconfig.test.json with the root typecheck runner;
  locally they use incremental tsrs (Bun elsewhere), CI uses Bun like root CI.
- Route the tests-typecheck ratchet through the same compiler selection.
- Enforce root/mobile parity for typescript, typescript-api and vitest.
2026-10-24 23:09:20 -07:00

59 lines
2.1 KiB
JavaScript

import path from 'node:path'
import { describe, expect, it } from 'vitest'
import {
findSharedDependencyVersionProblems,
main
} from './check-mobile-shared-dependency-versions.mjs'
const projectDir = path.resolve(import.meta.dirname, '../..')
const locked = (version) => ({ dependencies: { zod: { specifier: '~4.6.0', version } } })
const checkZod = (rootImporter, mobileImporter) =>
findSharedDependencyVersionProblems({ rootImporter, mobileImporter, names: ['zod'] })
describe('findSharedDependencyVersionProblems', () => {
it('passes when both lockfiles resolve the same version', () => {
expect(checkZod(locked('4.6.7'), locked('4.6.7'))).toEqual([])
})
it('reports two resolved versions', () => {
expect(checkZod(locked('4.6.7'), locked('4.6.5'))).toEqual([
'zod: the root locks 4.6.7, mobile locks 4.6.5'
])
})
it('ignores peer and patch suffixes and reads devDependencies', () => {
expect(
checkZod(
{ devDependencies: { zod: { version: '4.6.7(typescript@6.0.3)' } } },
locked('4.6.7(patch_hash=abc)')
)
).toEqual([])
})
it('reports a side that stopped declaring the dependency', () => {
expect(checkZod(locked('4.6.7'), {})).toEqual(['zod is not a direct dependency of mobile'])
expect(checkZod({}, locked('4.6.7'))).toEqual(['zod is not a direct dependency of the root'])
})
it('checks every shared and toolchain dependency by default', () => {
const problems = findSharedDependencyVersionProblems({
rootImporter: locked('4.6.7'),
mobileImporter: locked('4.6.7')
})
expect(problems).toEqual([
'tweetnacl is not a direct dependency of the root',
'@noble/hashes is not a direct dependency of the root',
'@types/ws is not a direct dependency of the root',
'typescript is not a direct dependency of the root',
'typescript-api is not a direct dependency of the root',
'vitest is not a direct dependency of the root'
])
})
})
describe('committed lockfiles', () => {
it('pass the repository check', () => {
expect(main(projectDir)).toBe(0)
})
})