Files
directus/tests/blackbox/common/seed-database.test.ts
Pascal Jufer 15b91dee34 Blackbox tests restructuring (#18122)
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: ian <licitdev@gmail.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-04-11 18:28:37 +02:00

38 lines
886 B
TypeScript

import globby from 'globby';
import * as common from '@common/index';
import { list } from '../setup/sequentialTests';
describe('Seed Database Structure', () => {
common.DisableTestCachingSetup();
let paths = globby.sync('**.seed.ts', {
cwd: `${__dirname}/../`,
});
if (paths.length === 0) {
test('No seed files found', () => {
expect(true).toBe(true);
});
} else if (list.only.length > 0) {
const requiredPaths = list.only.map((testEntry) => {
return testEntry.testFilePath.slice(1).replace('.test.ts', '.seed.ts');
});
paths = paths.filter((path) => {
return requiredPaths.includes(path);
});
}
for (const path of paths) {
const importedTest = require(`../${path}`);
if (typeof importedTest.seedDBStructure === 'function') {
describe(`Seeding "${path}"`, () => {
importedTest.seedDBStructure();
});
}
}
common.ClearCaches();
});