Skip to content

Commit

Permalink
Update export test to avoid "ExperimentalWarning: Importing JSON modu…
Browse files Browse the repository at this point in the history
…les is an experimental feature and might change at any time".
  • Loading branch information
DavidAnson committed Dec 24, 2024
1 parent 8e5f699 commit df33933
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/markdownlint-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,15 +1388,20 @@ test("exportMappings", (t) => {
});

const jsonRe = /\.json$/u;
const importOptionsJson = { "with": { "type": "json" } };
// ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
// const importOptionsJson = { "with": { "type": "json" } };

for (const [ exportName, exportPath ] of exportMappings) {
test(exportName, async(t) => {
const json = jsonRe.test(exportPath);
const importOptions = json ? importOptionsJson : undefined;
const importExportName = await import(exportName.replace(/^\./u, packageJson.name), importOptions);
const importExportPath = await import(exportPath, importOptions);
t.is(importExportName, importExportPath);
const exportByName = exportName.replace(/^\./u, packageJson.name);
const importExportByName = json ?
require(exportByName) :
await import(exportByName);
const importExportByPath = json ?
require(exportPath) :
await import(exportPath);
t.is(importExportByName, importExportByPath);
});
}

Expand Down

0 comments on commit df33933

Please sign in to comment.