Skip to content

Commit

Permalink
Remove wrong commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dheesen committed Jan 22, 2025
1 parent d944d95 commit 6fbe133
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions playwright.config.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,22 @@ import fs from "node:fs";
dotenv.config({ path: path.resolve(__dirname, '.env') });

function getTestFiles(baseDir: string, customDir: string): string[] {
const baseFiles = new Set(fs.readdirSync(baseDir).filter(file => file.endsWith('.spec.ts')));
const customFiles = fs.readdirSync(customDir).filter(file => file.endsWith('.spec.ts'));
const testFiles = new Set<string>();

function getAllFiles(dir: string): string[] {
const files = fs.readdirSync(dir, { withFileTypes: true });
const allFiles: string[] = [];
for (const file of files) {
const fullPath = path.join(dir, file.name);
if (file.isDirectory()) {
allFiles.push(...getAllFiles(fullPath));
} else {
allFiles.push(fullPath);
}
}
return allFiles;
}

const baseFiles = getAllFiles(baseDir);
const customFiles = getAllFiles(customDir);

const baseRelativePaths = new Map(
baseFiles.map((file) => [path.relative(baseDir, file), file])
);

const customRelativePaths = new Map(
customFiles.map((file) => [path.relative(customDir, file), file])
);
// Get base files that have an override in custom
for (const file of baseFiles) {
const baseFilePath = path.join(baseDir, file);
const customFilePath = path.join(customDir, file);

for (const [relativePath, baseFilePath] of baseRelativePaths.entries()) {
const customFilePath = customRelativePaths.get(relativePath);
testFiles.add(customFilePath || baseFilePath);
testFiles.add(fs.existsSync(customFilePath) ? customFilePath : baseFilePath);
}

for (const [relativePath, customFilePath] of customRelativePaths.entries()) {
if (!baseRelativePaths.has(relativePath)) {
testFiles.add(customFilePath);
// Add custom tests that aren't in base
for (const file of customFiles) {
if (!baseFiles.has(file)) {
testFiles.add(path.join(customDir, file));
}
}

Expand Down

0 comments on commit 6fbe133

Please sign in to comment.