Skip to content

Commit e89e237

Browse files
committed
fix(tests): resolve formatter path from test file location for CI
1 parent 3185feb commit e89e237

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it, expect } from 'vitest'
2-
import { join } from 'path'
2+
import { join, dirname } from 'path'
3+
import { fileURLToPath } from 'url'
34
import { createRequire } from 'module'
45

56
/**
@@ -9,6 +10,8 @@ import { createRequire } from 'module'
910
*/
1011

1112
const require = createRequire(import.meta.url)
13+
const __dirname = dirname(fileURLToPath(import.meta.url))
14+
const projectRoot = join(__dirname, '..', '..', '..')
1215

1316
function createMockResult(overrides: Record<string, unknown> = {}) {
1417
return {
@@ -51,7 +54,7 @@ function createCleanResult() {
5154
}
5255

5356
describe('Formatter Output', () => {
54-
const formatterPath = join(process.cwd(), 'dist/linter/eslint-plugin/formatter.js')
57+
const formatterPath = join(projectRoot, 'dist/linter/eslint-plugin/formatter.js')
5558
const formatterModule = require(formatterPath)
5659

5760
describe('default formatter', () => {
@@ -102,7 +105,7 @@ describe('Formatter Output', () => {
102105
})
103106

104107
describe('Formatter With Progress Output', () => {
105-
const formatterPath = join(process.cwd(), 'dist/linter/eslint-plugin/formatter-with-progress.js')
108+
const formatterPath = join(projectRoot, 'dist/linter/eslint-plugin/formatter-with-progress.js')
106109
const formatterModule = require(formatterPath)
107110

108111
describe('progress formatter', () => {

0 commit comments

Comments
 (0)