theatre/compat-tests/integrity.compat-test.ts

52 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

import * as path from 'path'
import * as fs from 'fs'
2023-07-30 15:41:09 +02:00
describe(`Compat tests`, () => {
2023-08-06 17:18:35 +02:00
test(`all fixtures prefixed with 'r3f-' should have an App/ directory identical to that of vite4's`, async () => {
const vite4AppDir = path.join(
__dirname,
'./fixtures/r3f-vite4/package/src/App',
)
2023-07-30 15:41:09 +02:00
const vite4FilesContents = fs
.readdirSync(vite4AppDir)
.map((file) => [
file,
fs.readFileSync(path.join(vite4AppDir, file), 'utf-8'),
])
const allFixtures = fs
.readdirSync(path.join(__dirname, './fixtures'))
.filter(
(fixture) =>
2023-08-06 17:18:35 +02:00
fixture !== 'r3f-vite4' &&
fixture.startsWith('r3f-') &&
2023-07-30 15:41:09 +02:00
// item is a folder
fs
.lstatSync(path.join(__dirname, './fixtures', fixture))
.isDirectory(),
)
for (const fixture of allFixtures) {
const appDir = path.join(
__dirname,
`./fixtures/${fixture}/package/src/App`,
)
if (!fs.existsSync(appDir)) {
throw new Error(`Fixture ${fixture} does not have an App/ directory`)
}
for (const [file, contents] of vite4FilesContents) {
const fixtureFileContents = fs.readFileSync(
path.join(appDir, file),
'utf-8',
)
if (fixtureFileContents !== contents) {
throw new Error(
`The file ${file} in fixture ${fixture} is not identical to that of vite4's`,
)
}
}
}
})
})