diff --git a/test/e2e/__tests__/stylelint-resolution.ts b/test/e2e/__tests__/stylelint-resolution.ts index e4f5820b..020e0fc6 100644 --- a/test/e2e/__tests__/stylelint-resolution.ts +++ b/test/e2e/__tests__/stylelint-resolution.ts @@ -1,38 +1,65 @@ -import path from 'path'; -import { normalizeDiagnostic } from '../utils'; +import { openDocument, waitForDiagnostics, assertDiagnostics, closeAllEditors } from '../utils'; describe('Stylelint resolution', () => { + afterEach(async () => { + await closeAllEditors(); + }); + it('should resolve Stylelint using local node_modules', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/local-stylelint/test.css'), - ); + const document = await openDocument('defaults/local-stylelint/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from resolve-local', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); - it('should resolve Stylelint using "stylelint.stylelintPath"', async () => { - const { document } = await openDocument(path.resolve(workspaceDir, 'stylelint-path/test.css')); - const diagnostics = await waitForDiagnostics(document); + describe('when using "stylelint.stylelintPath"', () => { + it('should resolve Stylelint', async () => { + const document = await openDocument('stylelint-path/test.css'); + const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); + }); }); it('should resolve Stylelint using PnP', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/yarn-pnp/test.css'), - ); + const document = await openDocument('defaults/yarn-pnp/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from yarn-pnp', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); it('should resolve Stylelint using Yarn 2.x PnP', async () => { - const { document } = await openDocument( - path.resolve(workspaceDir, 'defaults/yarn-2-pnp/test.css'), - ); + const document = await openDocument('defaults/yarn-2-pnp/test.css'); const diagnostics = await waitForDiagnostics(document); - expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); + assertDiagnostics(diagnostics, [ + { + code: 'fake', + message: 'Fake result from yarn-2-pnp', + range: [0, 0, 0, 1], + severity: 'error', + }, + ]); }); });