Skip to content

Commit ae87dd3

Browse files
committed
test: imrpove smoke tests
1 parent f5ee080 commit ae87dd3

6 files changed

+66
-16
lines changed

smoke-tests/smoke-test-cjs-sync.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ TypeScriptLoaderSync();
2020

2121
console.info("Loaded with CJS successfully");
2222
} catch (error) {
23-
console.error(error);
24-
console.debug(error.stack);
25-
console.error("Failed to load with CJS");
23+
console.error("Failed to load configuration with CJS");
24+
if (error instanceof TypeError) {
25+
console.error("Type error occurred:", error.message);
26+
} else if (error instanceof SyntaxError) {
27+
console.error("Syntax error in configuration file:", error.message);
28+
} else {
29+
console.error("An unexpected error occurred:", error.message);
30+
}
31+
console.debug("Error stack trace:", error.stack);
2632
process.exit(1);
2733
}
2834
})();

smoke-tests/smoke-test-cjs.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ TypeScriptLoader();
2020

2121
console.info("Loaded with CJS successfully");
2222
} catch (error) {
23-
console.error(error);
24-
console.debug(error.stack);
25-
console.error("Failed to load with CJS");
23+
console.error("Failed to load configuration with CJS");
24+
if (error instanceof TypeError) {
25+
console.error("Type error occurred:", error.message);
26+
} else if (error instanceof SyntaxError) {
27+
console.error("Syntax error in configuration file:", error.message);
28+
} else {
29+
console.error("An unexpected error occurred:", error.message);
30+
}
31+
console.debug("Error stack trace:", error.stack);
2632
process.exit(1);
2733
}
2834
})();

smoke-tests/smoke-test-esm-sync.mjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ TypeScriptLoaderSync();
2020

2121
console.info("Loaded with ESM successfully");
2222
} catch (error) {
23-
console.error(error);
24-
console.debug(error.stack);
25-
console.error("Failed to load with ESM");
23+
console.error("Failed to load configuration with ESM");
24+
if (error instanceof TypeError) {
25+
console.error("Type error occurred:", error.message);
26+
} else if (error instanceof SyntaxError) {
27+
console.error("Syntax error in configuration file:", error.message);
28+
} else {
29+
console.error("An unexpected error occurred:", error.message);
30+
}
31+
console.debug("Error stack trace:", error.stack);
2632
process.exit(1);
2733
}
2834
})();

smoke-tests/smoke-test-esm.mjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ TypeScriptLoader();
2020

2121
console.info("Loaded with ESM successfully");
2222
} catch (error) {
23-
console.error(error);
24-
console.debug(error.stack);
25-
console.error("Failed to load with ESM");
23+
console.error("Failed to load configuration with ESM");
24+
if (error instanceof TypeError) {
25+
console.error("Type error occurred:", error.message);
26+
} else if (error instanceof SyntaxError) {
27+
console.error("Syntax error in configuration file:", error.message);
28+
} else {
29+
console.error("An unexpected error occurred:", error.message);
30+
}
31+
console.debug("Error stack trace:", error.stack);
2632
process.exit(1);
2733
}
2834
})();

smoke-tests/smoke-test-sync.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@ const assert = require("node:assert");
1212
assert.strictEqual(typeof cjs === "function", true);
1313

1414
// Try to create loaders
15-
esm();
16-
cjs();
15+
const esmResult = esm({});
16+
const cjsResult = cjs({});
17+
18+
assert.strictEqual(
19+
typeof esmResult,
20+
"function",
21+
"ESM loader should return an function",
22+
);
23+
assert.strictEqual(
24+
typeof cjsResult,
25+
"function",
26+
"CJS loader should return an function",
27+
);
1728

1829
console.info("Loaded with both CJS and ESM successfully");
1930
} catch (error) {

smoke-tests/smoke-test.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,23 @@ const assert = require("node:assert");
1212
assert.strictEqual(typeof cjs === "function", true);
1313

1414
// Try to create loaders
15-
esm();
16-
cjs();
15+
const esmResult = await esm({
16+
/* mock config */
17+
});
18+
const cjsResult = await cjs({
19+
/* mock config */
20+
});
21+
22+
assert.strictEqual(
23+
typeof esmResult,
24+
"function",
25+
"ESM loader should return an function",
26+
);
27+
assert.strictEqual(
28+
typeof cjsResult,
29+
"function",
30+
"CJS loader should return an function",
31+
);
1732

1833
console.info("Loaded with both CJS and ESM successfully");
1934
} catch (error) {

0 commit comments

Comments
 (0)