Repository: nuxt/nuxt
File: packages/nuxt/test/pages.test.ts (TypeScript)

Code before:
import type { NuxtPage } from 'nuxt/schema'
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { augmentPages, generateRoutesFromFiles, normalizeRoutes, pathToNitroGlob } from '../src/pages/utils'
import type { RouterViewSlotProps } from '../src/pages/runtime/utils'
import { generateRouteKey } from '../src/pages/runtime/utils'

describe('pages:generateRoutesFromFiles', () => {
  const pagesDir = 'pages'
  const layerDir = 'layer/pages'
  const DYNAMIC_META_KEY = '__nuxt_dynamic_meta_key' as const

  vi.mock('knitwork', async (original) => {
    return {
      ...(await original<typeof import('knitwork')>()),
      genArrayFromRaw: (val: any) => val,
      genSafeVariableName: (..._args: string[]) => {
        return 'mock'
      },
    }
  })

  const tests: Array<{
    description: string
    files?: Array<{ path: string, template?: string, meta?: Record<string, any> }>
    output?: NuxtPage[]
    focus?: boolean
    normalized?: Record<string, any>[]
    error?: string
  }> = [
    {
      description: 'should generate correct routes for index pages',
      files: [
        { path: `${pagesDir}/index.vue` },
        { path: `${pagesDir}/parent/index.vue` },
        { path: `${pagesDir}/parent/child/index.vue` },
      ],
      output: [
        {
          name: 'index',
          path: '/',
          file: `${pagesDir}/index.vue`,
          children: [],
        },
        {
          name: 'parent',
          path: '/parent',
          file: `${pagesDir}/parent/index.vue`,
          children: [],
        },
        {
          name: 'parent-child',

Review comment (bug):
Can you explain your thinking behind Focus instead of Flexible Test Variants? I thought it might be good to allow committing failing or todo tests as well.

Code after:
import { describe, expect, it, vi } from 'vitest'
import type { NuxtPage } from 'nuxt/schema'
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { augmentPages, generateRoutesFromFiles, normalizeRoutes, pathToNitroGlob } from '../src/pages/utils'
import type { RouterViewSlotProps } from '../src/pages/runtime/utils'
import { generateRouteKey } from '../src/pages/runtime/utils'

describe('pages:generateRoutesFromFiles', () => {
  const pagesDir = 'pages'
  const layerDir = 'layer/pages'
  const DYNAMIC_META_KEY = '__nuxt_dynamic_meta_key' as const

  vi.mock('knitwork', async (original) => {
    return {
      ...(await original<typeof import('knitwork')>()),
      genArrayFromRaw: (val: any) => val,
      genSafeVariableName: (..._args: string[]) => {
        return 'mock'
      },
    }
  })

  const tests: Array<{
    description: string
    files?: Array<{ path: string, template?: string, meta?: Record<string, any> }>
    output?: NuxtPage[]
    it?: TestAPI
    normalized?: Record<string, any>[]
    error?: string
  }> = [
    {
      description: 'should generate correct routes for index pages',
      files: [
        { path: `${pagesDir}/index.vue` },
        { path: `${pagesDir}/parent/index.vue` },
        { path: `${pagesDir}/parent/child/index.vue` },
      ],
      output: [
        {
          name: 'index',
          path: '/',
          file: `${pagesDir}/index.vue`,
          children: [],
        },
        {
          name: 'parent',
          path: '/parent',
          file: `${pagesDir}/parent/index.vue`,
          children: [],
        },
        {