All files / src/commands/test index.ts

0% Statements 0/19
0% Branches 0/5
0% Functions 0/3
0% Lines 0/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
import fs from 'fs'
import { join } from 'path'
 
import { appsCachePath } from '../../consts'
import { fixtures, targets } from '../init'
 
export async function validateTestRun(app: string, dist: string): Promise<{ error: string | null }> {
  const indexHtmlPath = join(process.cwd(), appsCachePath, app, dist, 'index.html')
  const indexHtmlExists = await fs.promises.stat(indexHtmlPath).catch(() => false)
 
  Iif (!indexHtmlExists) {
    return { error: 'index.html not found. Check if the app was built correctly' }
  }
 
  return { error: null }
}
 
export function validateSnapshotsUpdate(targetFixtures: typeof fixtures) {
  const fixture = targetFixtures[0]
  const numberOfFixtures = targetFixtures.length
  const target = targets[0]
 
  const canUpdateSnashots = numberOfFixtures === 1
    && fixture.stack === target.stack
    && fixture.version === target.versions[target.versions.length - 1]
 
  Iif (!canUpdateSnashots) {
    return { error: 'You can update snapshots only for the latest version of React' }
  }
 
  return { error: null }
}