Skip to content

[BUG] Runtime error (TypeError: (0 , common_1.guessLocationOfTsconfig) is not a function) in Vitest 4 #8

@doberkofler

Description

@doberkofler

Bug Report

When trying to run ArchUnitTS in Vitest 4 i get a runtime error TypeError: (0 , common_1.guessLocationOfTsconfig) is not a function

Steps to Reproduce

vitest.config.ts

import path from 'node:path';

export default defineConfig({
	build: {
		target: 'es2022',
	},
	resolve: {
		preserveSymlinks: true,
		alias: {
			'@alias_root': path.resolve('./'),
		},
	},
	test: {
		globals: true,
		environment: 'node',
		coverage: {
			provider: 'v8',
			reporter: ['text', 'json', 'html'],
		},
		include: ['test/unittest/archunit/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
	},
});

archunit.test.ts

/// <reference types="vitest/globals" />

import {projectFiles, metrics} from 'archunit';

describe('Architecture Tests', () => {
	it('should not contain too large files', async () => {
		const rule = metrics().count().linesOfCode().shouldBeBelow(1000);
		await expect(rule).toPassAsync();
	});
});
> vitest run --config=scripts/vitest.archunit.config.ts


 RUN  v4.0.2 /Users/doberkofler/MyDev/ljs_app/trunk/periscope

 ❯ test/unittest/archunit/archunit.test.ts (4 tests | 1 failed | 3 skipped) 5ms
   ❯ Architecture Tests (4)
     × should not contain too large files 4ms
     ↓ should not have circular dependencies
     ↓ presentation layer should not depend on database layer
     ↓ should only have classes with high cohesion

 FAIL  test/unittest/archunit/archunit.test.ts > Architecture Tests > should not contain too large files
TypeError: (0 , common_1.guessLocationOfTsconfig) is not a function
 ❯ FileCountThresholdBuilder.check node_modules/archunit/dist/src/metrics/fluentapi/metrics/count-metrics.js:337:105
 ❯ Object.toPassAsync node_modules/archunit/dist/src/testing/vitest/vitest-adapter.js:44:48
 ❯ test/unittest/archunit/archunit.test.ts:8:22
      6|  it('should not contain too large files', async () => {
      7|   const rule = metrics().count().linesOfCode().shouldBeBelow(1000);
      8|   await expect(rule).toPassAsync();
       |                      ^
      9|  });
     10| 

Environment

  • OS: macOS 15.7.1
  • Node.js: 24.10
  • ArchUnitTS: 2.1.63
  • Testing Framework: Vitest 4.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions