/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
test/unit/vitest.config.mjs
96 строк
2 KB
Marco Ciampini
Test: Add private Vitest config and migrate a pilot test (#81037)
11 авг 2026, 13:45
Не верифицирован
11 авг 2026, 13:45
9f8d048
Код
Авторство
О чём код?
import { readFileSync } from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { playwright } from '@vitest/browser-playwright'; import { defineConfig } from 'vitest/config'; import { discoverTestFiles, getVitestTestsByProject, } from './scripts/discover-test-files.mjs'; const ROOT_DIR = path.resolve( path.dirname( fileURLToPath( import.meta.url ) ), '../..' ); const testMigration = JSON.parse( readFileSync( path.join( ROOT_DIR, 'test/unit/test-migration.json' ), 'utf8' ) ); const vitestTests = getVitestTestsByProject( discoverTestFiles( ROOT_DIR ), testMigration ); // Preserve Jest's repository-root configuration discovery and default timezone. process.chdir( ROOT_DIR ); process.env.TZ = 'UTC'; export default defineConfig( { root: ROOT_DIR, test: { projects: [ { extends: true, test: { name: 'node', environment: 'node', include: vitestTests.node, }, }, { extends: true, test: { name: 'jsdom', environment: 'jsdom', environmentOptions: { jsdom: { url: 'http://localhost/', }, }, include: vitestTests.jsdom, }, }, { extends: true, test: { name: 'browser', include: vitestTests.browser, browser: { enabled: true, headless: true, instances: [ { browser: 'chromium' } ], provider: playwright(), }, }, }, ], globals: false, includeTaskLocation: true, passWithNoTests: false, reporters: process.env.CI && process.env.GITHUB_REPOSITORY === 'WordPress/gutenberg' ? [ 'default', 'github-actions', [ '@flakiness/vitest', { duplicates: 'rename', flakinessProject: 'WordPress/gutenberg', }, ], ] : [ 'default' ], sequence: { hooks: 'list', setupFiles: 'list', }, snapshotFormat: { escapeString: false, printBasicPrototype: false, }, }, } );