forked from DanielRamosAcosta/testing-library-koans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheject.mjs
34 lines (25 loc) · 1.03 KB
/
eject.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { readFileSync, writeFileSync } from "node:fs";
deleteLineNumbers("01-GetByText", [7, 8, 9, 10]);
deleteLineNumbers("02-FindByText", [7, 8, 9, 10]);
deleteLineNumbers("03-GetAllByText", [7, 8, 9, 10]);
deleteLineNumbers("04-GetByRole", [7, 8, 9, 10]);
deleteLineNumbers("05-GetByLabel", [7, 8, 9, 10]);
deleteLineNumbers("06-GetIconByLabel", [7, 8, 9, 10]);
deleteLineNumbers("07-GetByPlaceholder", [7, 8, 9, 10]);
deleteLineNumbers("08-Click", [8, 9, 10, 11, 12]);
deleteLineNumbers("09-Hover", [8, 9, 10, 11, 12]);
deleteLineNumbers("10-Type", [8, 9, 10, 11, 12]);
function createPathToTest(name) {
const base = name.split("-")[1];
return `src/koans/${name}/${base}.test.tsx`;
}
function deleteLineNumbers(name, lines) {
const path = createPathToTest(name);
const data = readFileSync(path, "utf8");
const linesArray = data.split("\n");
const newLines = linesArray.filter((line, index) => {
return !lines.includes(index + 1);
});
const modifiedData = newLines.join("\n");
writeFileSync(path, modifiedData, "utf8");
}