(config: Config)
| 88 | } |
| 89 | |
| 90 | function deleteSnapshots(config: Config) { |
| 91 | try { |
| 92 | const absoluteSnapshotDirectory = normalizeResolvePath(config.snapshotDirectory); |
| 93 | const items: SandboxFileInformation[] = require(SANDBOX_MENU_ITEMS_FILE).getSandboxMenuItems(); |
| 94 | const buildIdentifier = (url) => { |
| 95 | return decodeURIComponent(url) |
| 96 | .substr(2) |
| 97 | .replace(/[\/.]|\s+/g, '-') |
| 98 | .replace(/[^a-z0-9\-]/gi, ''); |
| 99 | }; |
| 100 | |
| 101 | let filesDeleted = false; |
| 102 | items.forEach((item) => { |
| 103 | item.scenarioMenuItems.forEach((scenarioItem) => { |
| 104 | if (!config.pathToSandboxes || config.pathToSandboxes.some(vp => item.key.includes(vp))) { |
| 105 | const url = `${encodeURIComponent(item.key)}/${encodeURIComponent(scenarioItem.description)}`; |
| 106 | const filePath = `${absoluteSnapshotDirectory}/${buildIdentifier(url)}-snap.png`; |
| 107 | if (existsSync(filePath)) { |
| 108 | unlinkSync(filePath); |
| 109 | console.log(`Deleted file: ${filePath}`); |
| 110 | filesDeleted = true; |
| 111 | } |
| 112 | } |
| 113 | }); |
| 114 | }); |
| 115 | if (!filesDeleted) { |
| 116 | console.log('No snapshots were deleted.'); |
| 117 | } |
| 118 | } catch (err) { |
| 119 | throw new Error(`Failed to delete snapshots. ${err}`); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | function writeSandboxesToTestFile(config: Config, hostUrl: string, testPath: string, viewportConfig?: ViewportOptions) { |
| 124 | const absoluteSnapshotDirectory = normalizeResolvePath(config.snapshotDirectory); |
no test coverage detected