message: enabled grouping of test cases to directories
diff: @@ -20,9 +20,7 @@ type TestCases = {
  name: string;
  }[];
  -export function fetchTestCases(): TestCases {
  -
  - const importCase = async (dirent: Dirent): Promise<TestCase | undefined> => {
  +const importCase = async (basePath: string, dirent: Dirent): Promise<TestCase | undefined> => {
  // The case must be a folder
  if (!dirent.isDirectory()) {
  return undefined;
  @@ -35,7 +33,7 @@ export function fetchTestCases(): TestCases {
  if (absolute) {
  return subpath
  } else {
  - return path.join(root, dirent.name, subpath);
  + return path.join(basePath, dirent.name, subpath);
  }
  }
  @@ -109,7 +107,7 @@ export function fetchTestCases(): TestCases {
  input.schemas.query = {
  schema: queryInput,
  absolutePath: path.join(
  - root,
  + basePath,
  dirent.name,
  "input/query.graphql"
  ),
  @@ -120,7 +118,7 @@ export function fetchTestCases(): TestCases {
  input.schemas.mutation = {
  schema: mutationInput,
  absolutePath: path.join(
  - root,
  + basePath,
  dirent.name,
  "input/mutation.graphql"
  ),
  @@ -159,14 +157,33 @@ export function fetchTestCases(): TestCases {
  };
  };
  +export function fetchTestCases(): TestCases {
  const testCases: TestCases = [];
  readdirSync(root, { withFileTypes: true }).forEach(
  - (value: Dirent) => testCases.push({
  - promise: importCase(value),
  - name: value.name
  - })
  + (dirent: Dirent) => {
  + buildTestCases(root, root, dirent, testCases)
  + }
  );
  return testCases;
  }
  +
  +export const buildTestCases = (rootPath: string, basePath: string, dirent: Dirent, testCases: TestCases) => {
  + const fullPath = path.join(basePath, dirent.name);
  +
  + const items = readdirSync(fullPath, { withFileTypes: true });
  +
  + if(items.some(x => x.name === "input") &&
  + items.some(x => x.name === "output")
  + ) {
  + testCases.push({
  + promise: importCase(basePath, dirent),
  + name: path.relative(rootPath, fullPath),
  + });
  + } else {
  + for(const item of items) {
  + buildTestCases(rootPath, fullPath, item, testCases);
  + }
  + }
  +}
  \ No newline at end of file
  