Skip to content

Commit 544cc3c

Browse files
committed
fix(ci): align formatter-output test project root with other integration tests
1 parent fceef1d commit 544cc3c

3 files changed

Lines changed: 33 additions & 10 deletions

File tree

tests/vitest/integration/core-export.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ describe('./core export', () => {
5353
})
5454

5555
it('should export A11yChecker via ESM dist (import)', async () => {
56-
const coreModule = await import('../../../dist/index.mjs')
56+
const coreMjsPath = join(process.cwd(), 'dist/index.mjs')
57+
const coreModule = await import(coreMjsPath)
5758
expect(coreModule.A11yChecker).toBeDefined()
5859
expect(typeof coreModule.A11yChecker).toBe('function')
5960
})

tests/vitest/integration/formatter-output.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const require = createRequire(import.meta.url)
1414

1515
function getProjectRoot(): string {
1616
const fromCwd = process.cwd()
17-
const distFromCwd = resolve(fromCwd, 'dist/linter/eslint-plugin/formatter.js')
18-
if (existsSync(distFromCwd)) return fromCwd
17+
const pluginFromCwd = resolve(fromCwd, 'dist/linter/eslint-plugin/index.js')
18+
if (existsSync(pluginFromCwd)) return fromCwd
1919
const fromFile = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..')
20-
const distFromFile = resolve(fromFile, 'dist/linter/eslint-plugin/formatter.js')
21-
if (existsSync(distFromFile)) return fromFile
20+
const pluginFromFile = resolve(fromFile, 'dist/linter/eslint-plugin/index.js')
21+
if (existsSync(pluginFromFile)) return fromFile
2222
throw new Error(
23-
`dist/formatter.js not found. Tried cwd=${fromCwd} and fileRoot=${fromFile}. Ensure npm run build ran first.`
23+
`dist/linter/eslint-plugin/index.js not found. Tried cwd=${fromCwd} and fileRoot=${fromFile}. Ensure npm run build ran first.`
2424
)
2525
}
2626

tests/vitest/unit/linter/plugin-structure.test.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1-
import { describe, it, expect } from 'vitest'
2-
// Import from built version to test the actual export
3-
// In a real scenario, users would import from 'eslint-plugin-test-a11y-js'
4-
import eslintPlugin from '../../../../dist/linter/eslint-plugin/index.js'
1+
import { describe, it, expect, beforeAll } from 'vitest'
2+
import { resolve, dirname } from 'path'
3+
import { fileURLToPath } from 'url'
4+
import { existsSync } from 'fs'
5+
import { createRequire } from 'module'
6+
7+
const require = createRequire(import.meta.url)
8+
9+
function getProjectRoot(): string {
10+
const fromCwd = process.cwd()
11+
const pluginFromCwd = resolve(fromCwd, 'dist/linter/eslint-plugin/index.js')
12+
if (existsSync(pluginFromCwd)) return fromCwd
13+
const fromFile = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..')
14+
const pluginFromFile = resolve(fromFile, 'dist/linter/eslint-plugin/index.js')
15+
if (existsSync(pluginFromFile)) return fromFile
16+
throw new Error(
17+
'dist/linter/eslint-plugin/index.js not found. Ensure npm run build ran first.'
18+
)
19+
}
20+
21+
let eslintPlugin: { meta?: { name?: string; version?: string }; rules?: Record<string, unknown>; configs?: Record<string, unknown> }
522

623
const ALL_RULE_NAMES = [
724
'accessible-emoji',
@@ -50,6 +67,11 @@ const ALL_RULE_NAMES = [
5067
]
5168

5269
describe('ESLint Plugin Structure', () => {
70+
beforeAll(() => {
71+
const root = getProjectRoot()
72+
eslintPlugin = require(resolve(root, 'dist/linter/eslint-plugin/index.js')).default
73+
})
74+
5375
it('should export a plugin object', () => {
5476
expect(eslintPlugin).toBeDefined()
5577
expect(typeof eslintPlugin).toBe('object')

0 commit comments

Comments
 (0)