Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions vitest.shared.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import * as path from 'node:path';
import type { ViteUserConfig } from 'vitest/config';

const alias = (pkg: string, dir = pkg) => {
const name = pkg === 'graph-framework' ? '@graphprotocol/graph-framework' : `@graph-framework/${pkg}`;
const graphFrameworkAlias = {
'@graphprotocol/graph-framework/test': path.join(__dirname, 'packages', 'graph-framework', 'test'),
'@graphprotocol/graph-framework': path.join(__dirname, 'packages', 'graph-framework', 'src'),
};

const graphFrameworkPkgAlias = (name: string) => {
return {
[`${name}/test`]: path.join(__dirname, 'packages', dir, 'test'),
[`${name}`]: path.join(__dirname, 'packages', dir, 'src'),
[`@graph-framework/${name}/test`]: path.join(__dirname, 'packages', `graph-framework-${name}`, 'test'),
[`@graph-framework/${name}`]: path.join(__dirname, 'packages', `graph-framework-${name}`, 'src'),
};
};

// This is a workaround, see https://github.com/vitest-dev/vitest/issues/4744
const config: ViteUserConfig = {
test: {
alias: {
...alias('graph-framework'),
...alias('graph-framework-utils'),
...alias('graph-framework-space-events'),
...alias('graph-framework-schema'),
...alias('graph-framework-identity'),
...alias('graph-framework-key'),
...alias('graph-framework-messages'),
...graphFrameworkAlias,
...graphFrameworkPkgAlias('utils'),
...graphFrameworkPkgAlias('space-events'),
...graphFrameworkPkgAlias('schema'),
...graphFrameworkPkgAlias('identity'),
...graphFrameworkPkgAlias('key'),
...graphFrameworkPkgAlias('messages'),
},
},
};
Expand Down
Loading