(workspaceRoot: string)
| 25 | } |
| 26 | |
| 27 | async function runCleanStateTest(workspaceRoot: string) { |
| 28 | const testFilePath = path.join(workspaceRoot, 'diagnostics_clean_test.ts'); |
| 29 | const uri = vscode.Uri.file(testFilePath); |
| 30 | |
| 31 | const fileContent = ` |
| 32 | import {Component} from '@angular/core'; |
| 33 | @Component({ |
| 34 | selector: 'app-diag-clean-test', |
| 35 | template: '<div>Hello World</div>', |
| 36 | standalone: true, |
| 37 | }) |
| 38 | export class AppDiagCleanTestComponent {} |
| 39 | `; |
| 40 | |
| 41 | console.log(`Creating clean file: ${testFilePath}`); |
| 42 | await fs.writeFile(testFilePath, fileContent); |
| 43 | |
| 44 | try { |
| 45 | console.log(`Open clean file: ${testFilePath}`); |
| 46 | const document = await vscode.workspace.openTextDocument(uri); |
| 47 | await vscode.window.showTextDocument(document); |
| 48 | |
| 49 | await new Promise((resolve) => setTimeout(resolve, 2000)); |
| 50 | |
| 51 | console.log(`Checking for no diagnostics...`); |
| 52 | const diagnostics = vscode.languages.getDiagnostics(uri); |
| 53 | const filteredDiagnostics = diagnostics.filter( |
| 54 | (d) => !d.message.includes('_t1') && !d.message.includes('Identifier expected'), |
| 55 | ); |
| 56 | console.log(`Found diagnostics: ${diagnostics.map((d) => d.message).join(', ')}`); |
| 57 | console.log(`Filtered diagnostics: ${filteredDiagnostics.map((d) => d.message).join(', ')}`); |
| 58 | assert.strictEqual( |
| 59 | filteredDiagnostics.length, |
| 60 | 0, |
| 61 | `Should return zero diagnostics for clean file after filtering noise, but found: ${filteredDiagnostics.map((d) => d.message).join(', ')}`, |
| 62 | ); |
| 63 | console.log('Clean state test passed!'); |
| 64 | } finally { |
| 65 | await vscode.commands.executeCommand('workbench.action.closeAllEditors'); |
| 66 | await cleanupFile(testFilePath); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | async function runSingleDiagnosticTest(workspaceRoot: string) { |
| 71 | const testFilePath = path.join(workspaceRoot, 'diagnostics_single_test.ts'); |
no test coverage detected