UNPKG

676 BPlain TextView Raw
1import path from 'path'
2import fs from 'fs'
3
4export function expectedFixture (fixtureFolder: string, fixtureName: string) {
5 const fixturePath = path.join(fixtureFolder, fixtureName)
6 const expectedPath = path.join(fixtureFolder, `${fixtureName}.expected`)
7
8 expect(fs.readFileSync(fixturePath, 'utf8')).toEqual(fs.readFileSync(expectedPath, 'utf8'))
9}
10
11export function cleanup (fixturePaths: Array<string>) {
12 for (let fixturePath of fixturePaths) {
13 let fullPath = fixture(fixturePath)
14 if (fs.existsSync(fullPath)) {
15 fs.unlinkSync(fullPath)
16 }
17 }
18}
19
20export function fixture (folder: string): string {
21 return path.join(__dirname, 'fixtures', folder)
22}