From e48dd59f00fd24d73bd60962aa6dda2712815682 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:51:18 +0900 Subject: [PATCH] Migrate `test/e2e/__tests__/report-needless-disables.ts` --- .vscode-test.js | 1 + .../e2e/__tests__/report-needless-disables.ts | 50 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.vscode-test.js b/.vscode-test.js index 2907bab1..c15162a3 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -11,6 +11,7 @@ if (!minimumVscodeVersion) throw new Error(`"engines.vscode" is unexpected: ${pk module.exports = defineConfig({ // TODO: files: ['test/e2e/__tests__/**/*.ts'], files: [ + 'test/e2e/__tests__/report-needless-disables.ts', 'test/e2e/__tests__/restart.ts', 'test/e2e/__tests__/stylelint-resolution.ts', 'test/e2e/__tests__/validate.ts', diff --git a/test/e2e/__tests__/report-needless-disables.ts b/test/e2e/__tests__/report-needless-disables.ts index 56536283..76d96c31 100644 --- a/test/e2e/__tests__/report-needless-disables.ts +++ b/test/e2e/__tests__/report-needless-disables.ts @@ -1,17 +1,47 @@ -import path from 'path'; -import { normalizeDiagnostic } from '../utils'; +import { openDocument, waitForDiagnostics, assertDiagnostics, closeAllEditors } from '../helpers'; describe('"stylelint.reportNeedlessDisables" setting', () => { + afterEach(async () => { + await closeAllEditors(); + }); + it('should report needless disables when enabled', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'report-disables/needless.css'), + const { document } = await openDocument('report-disables/needless.css'); + const diagnostics = (await waitForDiagnostics(document)).filter( + ({ code }) => code === '--report-needless-disables', ); - const diagnostics = await waitForDiagnostics(document); - expect( - diagnostics - .map(normalizeDiagnostic) - .filter((diagnostic) => diagnostic?.code === '--report-needless-disables'), - ).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: '--report-needless-disables', + message: 'Needless disable for "indentation"', + range: [2, 2, 2, 55], + severity: 'error', + }, + { + code: '--report-needless-disables', + message: 'Needless disable for "indentation"', + range: [6, 0, 6, 34], + severity: 'error', + }, + { + code: '--report-needless-disables', + message: 'Needless disable for "indentation"', + range: [14, 16, 14, 55], + severity: 'error', + }, + { + code: '--report-needless-disables', + message: 'Needless disable for "indentation"', + range: [17, 0, 17, 34], + severity: 'error', + }, + { + code: '--report-needless-disables', + message: 'Needless disable for "unknown"', + range: [2, 2, 2, 55], + severity: 'error', + }, + ]); }); });