Skip to content

Commit d855daa

Browse files
committed
test: Add simple pass log, handle the unhandled rejection case.
1 parent 7b2a575 commit d855daa

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

smoke-tests/smoke-test-cjs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
const mod = require("../dist/cjs/index.js");
22
const { TypeScriptLoader } = mod;
33
TypeScriptLoader();
4+
5+
console.info("Loaded with CJS successfully");

smoke-tests/smoke-test-esm.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import mod from "../dist/cjs/index.js";
2-
const {TypeScriptLoader} = mod;
3-
TypeScriptLoader()
2+
const { TypeScriptLoader } = mod;
3+
TypeScriptLoader();
4+
5+
console.info("Loaded with ESM successfully");

smoke-tests/smoke-test.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
const assert = require("node:assert");
22

3-
async function main() {
4-
const esm = await import("./dist/cjs/index.js");
5-
const cjs = require("./dist/cjs/index.js");
3+
(async () => {
4+
try {
5+
const esm = await import("../dist/cjs/index.js");
6+
const cjs = require("../dist/cjs/index.js");
67

7-
assert.equal(
8-
esm.TypeScriptLoader,
9-
cjs.TypeScriptLoader,
10-
"esm.TypeScriptLoader === cjs.TypeScriptLoader"
11-
);
8+
assert.strictEqual(
9+
esm.TypeScriptLoader,
10+
cjs.TypeScriptLoader,
11+
"esm.TypeScriptLoader === cjs.TypeScriptLoader"
12+
);
1213

13-
// try to create loaders
14-
esm.TypeScriptLoader();
15-
cjs.TypeScriptLoader();
16-
}
14+
// try to create loaders
15+
esm.TypeScriptLoader();
16+
cjs.TypeScriptLoader();
1717

18-
main();
18+
console.info("Loaded with both CJS and ESM successfully");
19+
} catch (error) {
20+
console.error(error);
21+
console.debug(error.stack);
22+
23+
// Prevent an unhandled rejection, exit gracefully.
24+
process.exit(1);
25+
}
26+
})();

0 commit comments

Comments
 (0)