Skip to content

Commit 938f23b

Browse files
committed
test(vscode): longer sleep for empty oxlint config test (#17027)
1 parent b8e7f59 commit 938f23b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

editors/vscode/tests/e2e_server_linter.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,20 @@ suite('E2E Server Linter', () => {
7676
});
7777
}
7878

79-
// TODO: fix flaky test, somehow broken since 25-12-16
79+
// TODO: fix flaky test, broken since 25-12-16
80+
// the `.oxlintrc.json` is not picked up correctly and `no-empty-file` is still enabled
8081
test.skip('detects diagnostics on run', async () => // testSingleFolderMode
8182
{
83+
// const config = new VSCodeConfig();
84+
// config.updateTrace('verbose');
85+
// await commands.executeCommand('oxc.showOutputChannel');
86+
8287
await loadFixture('lint_on_run');
8388
await sleep(500);
8489
const diagnostics = await getDiagnosticsWithoutClose(`onType.ts`);
85-
strictEqual(diagnostics.length, 0);
90+
// process.stdout.write(JSON.stringify(diagnostics, null, 2));
91+
92+
strictEqual(diagnostics.length, 0, 'no diagnostics expected initially');
8693

8794
await writeToFixtureFile('onType.ts', 'debugger;');
8895
await waitForDiagnosticChange();
@@ -92,15 +99,14 @@ suite('E2E Server Linter', () => {
9299
await workspace.saveAll();
93100
await sleep(500);
94101

95-
const sameDiagnostics = await getDiagnosticsWithoutClose(`onType.ts`);
102+
const sameDiagnostics = await getDiagnostics(`onType.ts`);
96103
strictEqual(updatedDiagnostics.length, sameDiagnostics.length);
97104
});
98105

99-
// TODO: fix flaky test, somehow broken since 25-12-16
100-
test.skip('empty oxlint configuration behaves like default configuration', async () => {
106+
test('empty oxlint configuration behaves like default configuration', async () => {
101107
await loadFixture('debugger_empty_config');
102108
await sleep(500);
103-
const diagnostics = await getDiagnosticsWithoutClose('debugger.js');
109+
const diagnostics = await getDiagnostics('debugger.js', undefined, 500);
104110

105111
strictEqual(diagnostics.length, 1);
106112
assert(typeof diagnostics[0].code == 'object');

editors/vscode/tests/test-helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ export async function loadFixture(fixture: string, workspaceDir: Uri = fixturesW
100100
await workspace.fs.copy(Uri.file(absolutePath), Uri.joinPath(workspaceDir, 'fixtures'), { overwrite: true });
101101
}
102102

103-
export async function getDiagnostics(file: string, workspaceDir: Uri = fixturesWorkspaceUri()): Promise<Diagnostic[]> {
104-
const diagnostics = await getDiagnosticsWithoutClose(file, workspaceDir);
103+
export async function getDiagnostics(file: string, workspaceDir: Uri = fixturesWorkspaceUri(), sleepDuration = 250): Promise<Diagnostic[]> {
104+
const diagnostics = await getDiagnosticsWithoutClose(file, workspaceDir, sleepDuration);
105105
await commands.executeCommand('workbench.action.closeActiveEditor');
106106
return diagnostics;
107107
}
108108

109-
export async function getDiagnosticsWithoutClose(file: string, workspaceDir: Uri = fixturesWorkspaceUri()): Promise<Diagnostic[]> {
109+
export async function getDiagnosticsWithoutClose(file: string, workspaceDir: Uri = fixturesWorkspaceUri(), sleepDuration = 250): Promise<Diagnostic[]> {
110110
const fileUri = Uri.joinPath(workspaceDir, 'fixtures', file);
111111
await window.showTextDocument(fileUri);
112-
await sleep(250);
112+
await sleep(sleepDuration);
113113
const diagnostics = languages.getDiagnostics(fileUri);
114114
return diagnostics;
115115
}

0 commit comments

Comments
 (0)