Skip to content

ui-router-server / ui-router-server / diagnoseMounts

Function: diagnoseMounts() ​

ts
function diagnoseMounts(router): MountDiagnostic[];

Defined in: index.ts:708

Checks the mounts a router was built with for configurations that compile but misroute, without logging: the findings the development build of createServerRouter warns about, returned in every build. It reports 'bareBaseNotFound' for a mount other than '/' whose bare base (/app) answers 404 — notFound, or the shell-404 of an otherwise projection. Findings follow the table's declaration order. Assert the result is empty in a test to catch them in CI.

Parameters ​

ParameterTypeDescription
routerServerRoutera router from this copy of the package's createServerRouter

Returns ​

MountDiagnostic[]

Throws ​

for any other object, such as a structural fake or a router from a second copy of the package

Example ​

ts
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { createServerRouter, diagnoseMounts } from 'ui-router-server';

// The table the server passes to createServerRouter.
const mounts = { '/app': { routes: [{ name: 'home', url: '' }] } };

test('every mount serves its bare base', () => {
  assert.deepEqual(diagnoseMounts(createServerRouter({ mounts })), []);
});