Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
package-details.spec.ts1.34 kB
import { readJsonFile } from '@nx-console/shared-file-system'; import { packageDetails } from './package-details'; import { normalize } from 'node:path'; jest.mock('@nx-console/shared-file-system'); describe('packageDetails', () => { it('should return package path, package name and JSON contents', async () => { const readJsonFileMock = jest.mocked(readJsonFile).mockResolvedValueOnce({ path: 'path', json: { name: 'utils', version: '1.0.0', main: 'dist/index.js', types: 'dist/index.d.ts', }, }); expect(await packageDetails('libs/utils')).toEqual({ packagePath: 'libs/utils', packageName: 'utils', packageJson: { name: 'utils', version: '1.0.0', main: 'dist/index.js', types: 'dist/index.d.ts', }, }); expect(readJsonFileMock).toHaveBeenCalledWith( normalize('libs/utils/package.json'), ); }); it('should return undefined package name if JSON is empty', async () => { const readJsonFileMock = jest.mocked(readJsonFile).mockResolvedValueOnce({ path: '', json: {}, }); expect(await packageDetails('')).toEqual({ packagePath: '', packageName: undefined, packageJson: {}, }); expect(readJsonFileMock).toHaveBeenCalledWith('package.json'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nrwl/nx-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server