1
0
mirror of synced 2026-01-04 09:06:46 -05:00
Files
docs/tests/meta/orphan-tests.js
Peter Bengtsson 26014646dd Massive DIFF_FILES crashes bash in repo-sync (#23326)
* Massive DIFF_FILES crashes bash in repo-sync

Part of #1304

* gst

* make exception
2021-12-02 18:57:38 +00:00

26 lines
849 B
JavaScript

import fs from 'fs/promises'
import path from 'path'
import { filter as asyncFilter } from 'async'
describe('check for orphan tests', () => {
test('all tests are in sub-directories', async () => {
// A known list of exceptions that can live outside of directories
const EXCEPTIONS = ['README.md', 'package.json', 'utils.js']
const pathToTests = path.join(process.cwd(), 'tests')
// Get a list of files/directories in `/tests`
const testDirectory = await fs.readdir(pathToTests)
// Filter out our exceptions
let filteredList = testDirectory.filter((item) => !EXCEPTIONS.includes(item))
// Don't include directories
filteredList = await asyncFilter(
filteredList,
async (item) => !(await fs.stat(path.join(pathToTests, item))).isDirectory()
)
expect(filteredList).toHaveLength(0)
})
})