diff --git a/.vscode-test.js b/.vscode-test.js index 8a31cc06..594430db 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__/lint.ts', 'test/e2e/__tests__/report-descriptionless-disables.ts', 'test/e2e/__tests__/report-invalid-scope-disables.ts', 'test/e2e/__tests__/report-needless-disables.ts', diff --git a/test/e2e/__tests__/lint.ts b/test/e2e/__tests__/lint.ts index cc5309e9..6aa933d2 100644 --- a/test/e2e/__tests__/lint.ts +++ b/test/e2e/__tests__/lint.ts @@ -1,18 +1,50 @@ -import path from 'path'; -import { normalizeDiagnostic } from '../utils'; +import { openDocument, waitForDiagnostics, assertDiagnostics, closeAllEditors } from '../helpers'; describe('Linting', () => { + afterEach(async () => { + await closeAllEditors(); + }); + it('should lint CSS documents', async () => { - const { document } = await openDocument(path.resolve(workspaceDir, 'defaults/lint.css')); + const document = await openDocument('defaults/lint.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'indentation', + codeDescription: 'https://stylelint.io/user-guide/rules/indentation', + message: 'Expected indentation of 4 spaces (indentation)', + range: [2, 2, 2, 13], + severity: 'error', + }, + ]); }); it('should display rule documentation links when one is available', async () => { - const { document } = await openDocument(path.resolve(workspaceDir, 'defaults/rule-doc.css')); + const document = await openDocument('defaults/rule-doc.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'plugin/foo-bar', + message: 'Bar (plugin/foo-bar)', + range: [0, 5, 0, 6], + severity: 'error', + }, + { + code: 'color-no-invalid-hex', + codeDescription: 'https://stylelint.io/user-guide/rules/color-no-invalid-hex', + message: 'Unexpected invalid hex color "#y3" (color-no-invalid-hex)', + range: [6, 11, 6, 14], + severity: 'error', + }, + { + code: 'indentation', + codeDescription: 'https://stylelint.io/user-guide/rules/indentation', + message: 'Expected indentation of 4 spaces (indentation)', + range: [2, 2, 2, 13], + severity: 'error', + }, + ]); }); });