mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update export test to avoid "ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time".
This commit is contained in:
parent
8e5f699bb2
commit
df33933fe5
1 changed files with 10 additions and 5 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue