Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940import { readFileSync, rmSync, writeFileSync } from 'node:fs'import { dirname, resolve } from 'pathe'import { afterEach, expect, test } from 'vitest'import { runVitest } from '../../test-utils'
const testFileName = resolve( import.meta.dirname, './fixtures/custom-snapshot-environment/test/snapshots.test.ts',)const snapshotFile = resolve(dirname(testFileName), './__snapshots__/snapshots.test.ts.snap')const testFile = readFileSync(testFileName, 'utf-8')
afterEach(() => { writeFileSync(testFileName, testFile) rmSync(snapshotFile)})
test('custom environment resolved correctly', async () => { const { stdout, stderr } = await runVitest({ root: resolve(import.meta.dirname, './fixtures/custom-snapshot-environment'), update: true, })
const snapshotLogs = stdout .split('\n') .filter((i) => i.startsWith('## ')) .join('\n') expect(stderr).toBe('') expect(snapshotLogs).toMatchInlineSnapshot(` "## resolvePath snapshots/fixtures/custom-snapshot-environment/test/snapshots.test.ts ## readSnapshotFile snapshots/fixtures/custom-snapshot-environment/test/__snapshots__/snapshots.test.ts.snap ## getHeader ## getVersion ## readSnapshotFile snapshots/fixtures/custom-snapshot-environment/test/__snapshots__/snapshots.test.ts.snap ## saveSnapshotFile snapshots/fixtures/custom-snapshot-environment/test/__snapshots__/snapshots.test.ts.snap ## readSnapshotFile snapshots/fixtures/custom-snapshot-environment/test/snapshots.test.ts ## saveSnapshotFile snapshots/fixtures/custom-snapshot-environment/test/snapshots.test.ts" `)})