Skip to content

Commit d81e036

Browse files
committed
Fix node-tests asserts being swallowed
1 parent b1d0dde commit d81e036

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/node-tests/rolldown.config.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ function testSuiteConfig(suitePath: string): RolldownOptions[] {
6464
delimiters: ["", ""],
6565
},
6666
),
67+
replacePlugin(
68+
{
69+
// Replace the default export to return a function instead of initializing the addon immediately
70+
// This allows the test runner to intercept any errors which would normally be thrown when importing
71+
// to work around Metro's `guardedLoadModule` swallowing errors during module initialization
72+
// See https://github.com/facebook/metro/blob/34bb8913ec4b5b02690b39d2246599faf094f721/packages/metro-runtime/src/polyfills/require.js#L348-L353
73+
"export default require_test();": "export default require_test;",
74+
},
75+
{
76+
delimiters: ["", ""],
77+
},
78+
),
6779
aliasPlugin({
6880
entries: [
6981
{

packages/node-tests/scripts/generate-entrypoint.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function suiteToString(suite: TestSuite, indent = 1): string {
3636
return Object.entries(suite)
3737
.map(([key, value]) => {
3838
if (typeof value === "string") {
39-
return `${padding}"${key}": () => require("./${value}")`;
39+
return `${padding}"${key}": require("./${value}")`;
4040
} else {
4141
return `${padding}"${key}": {\n${suiteToString(
4242
value,

0 commit comments

Comments
 (0)