test(docs): fix docs tests issues (#11307)

This commit is contained in:
Sébastien Lorber 2025-07-04 15:14:17 +02:00 committed by GitHub
parent da08536816
commit fad80c4421
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -62,6 +62,12 @@ async function createMdxLoaderDependencyFile({
options: PluginOptions;
versionsMetadata: VersionMetadata[];
}): Promise<string | undefined> {
// Disabled for unit tests, the side effect produces infinite watch loops
// TODO find a better way :/
if (process.env.NODE_ENV === 'test') {
return undefined;
}
const filePath = path.join(dataDir, '__mdx-loader-dependency.json');
// the cache is invalidated whenever this file content changes
const fileContent = {

View file

@ -38,6 +38,12 @@ type LoadVersionParams = {
function ensureNoDuplicateDocId(docs: DocMetadataBase[]): void {
const duplicatesById = _.chain(docs)
.sort((d1, d2) => {
// Need to sort because Globby order is non-deterministic
// TODO maybe we should create a deterministic glob utils?
// see https://github.com/sindresorhus/globby/issues/131
return d1.source.localeCompare(d2.source);
})
.groupBy((d) => d.id)
.pickBy((group) => group.length > 1)
.value();