refactor(v2): cleanup console output (#4979)

* refactor(v2): cleanup console output

* fix jest issue

Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2021-06-16 12:37:28 +03:00 committed by GitHub
parent 8501db78a1
commit 41d9288e3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 382 additions and 339 deletions

View file

@ -44,8 +44,10 @@ function getDocById(version: LoadedVersion, unversionedId: string) {
const doc = findDocById(version, unversionedId);
if (!doc) {
throw new Error(
`No doc found with id=${unversionedId} in version ${version.versionName}.
Available ids=\n- ${version.docs.map((d) => d.unversionedId).join('\n- ')}`,
`No doc found with id "${unversionedId}" in version ${
version.versionName
}.
Available ids are:\n- ${version.docs.map((d) => d.unversionedId).join('\n- ')}`,
);
}
return doc;
@ -85,7 +87,7 @@ const createFakeActions = (contentDir: string) => {
key.startsWith(prefix),
);
if (!entry) {
throw new Error(`No created entry found for prefix=[${prefix}]
throw new Error(`No created entry found for prefix "${prefix}".
Entries created:
- ${Object.keys(dataContainer).join('\n- ')}
`);
@ -151,8 +153,8 @@ describe('sidebar', () => {
);
await plugin.loadContent!();
}).rejects.toThrowErrorMatchingInlineSnapshot(`
"The path to the sidebar file does not exist at [wrong-path-sidebar.json].
Please set the docs [sidebarPath] field in your config file to:
"The path to the sidebar file does not exist at \\"wrong-path-sidebar.json\\".
Please set the docs \\"sidebarPath\\" field in your config file to:
- a sidebars path that exists
- false: to disable the sidebar
- undefined: for Docusaurus generates it automatically"
@ -217,7 +219,7 @@ describe('empty/no docs website', () => {
await expect(
plugin.loadContent!(),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Docs version current has no docs! At least one doc should exist at path=[docs]"`,
`"Docs version \\"current\\" has no docs! At least one doc should exist at \\"docs\\"."`,
);
});
@ -231,11 +233,11 @@ describe('empty/no docs website', () => {
}),
),
).toThrowError(
`The docs folder does not exist for version [current]. A docs folder is expected to be found at ${
`The docs folder does not exist for version "current". A docs folder is expected to be found at ${
process.platform === 'win32'
? 'path\\doesnt\\exist'
: 'path/doesnt/exist'
}`,
}.`,
);
});
});