forked from ChainLearnOfficial/chainlearn-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch13.js
More file actions
24 lines (23 loc) · 854 Bytes
/
Copy pathpatch13.js
File metadata and controls
24 lines (23 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require('fs');
const files = [
'src/components/layout/mobile-nav.test.tsx',
'src/components/layout/sidebar.test.tsx',
'src/tests/layout/mobile-nav.test.tsx',
'src/tests/layout/sidebar.test.tsx'
];
for (const file of files) {
if (!fs.existsSync(file)) continue;
let code = fs.readFileSync(file, 'utf8');
if (code.includes('beforeEach') && !code.includes('beforeEach } from "vitest"')) {
code = code.replace(
/import \{ describe, it, expect \} from "vitest";/,
`import { describe, it, expect, beforeEach } from "vitest";`
);
// if vi is imported separately, wait, it might be `describe, it, expect, vi`
code = code.replace(
/import \{ describe, it, expect, vi \} from "vitest";/,
`import { describe, it, expect, vi, beforeEach } from "vitest";`
);
}
fs.writeFileSync(file, code);
}