Skip to content

Commit be6cbec

Browse files
fix(unenv-preset): only check for throws when native tty module is enabled
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
1 parent 6cfc67c commit be6cbec

File tree

1 file changed

+12
-9
lines changed
  • packages/wrangler/e2e/unenv-preset/worker

1 file changed

+12
-9
lines changed

packages/wrangler/e2e/unenv-preset/worker/index.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,15 +881,18 @@ export const WorkerdTests: Record<string, () => void> = {
881881
assert.strictEqual(tty.isatty(1), false);
882882
assert.strictEqual(tty.isatty(2), false);
883883

884-
// Both implementations throw when calling ReadStream/WriteStream constructors
885-
assert.throws(
886-
() => new (tty.ReadStream as any)(0),
887-
/not implemented|ERR_METHOD_NOT_IMPLEMENTED/
888-
);
889-
assert.throws(
890-
() => new (tty.WriteStream as any)(1),
891-
/not implemented|ERR_METHOD_NOT_IMPLEMENTED/
892-
);
884+
// Native workerd throws when calling ReadStream/WriteStream constructors
885+
// unenv stub does not throw - it creates stub objects
886+
if (getRuntimeFlagValue("enable_nodejs_tty_module")) {
887+
assert.throws(
888+
() => new (tty.ReadStream as any)(0),
889+
/ERR_METHOD_NOT_IMPLEMENTED/
890+
);
891+
assert.throws(
892+
() => new (tty.WriteStream as any)(1),
893+
/ERR_METHOD_NOT_IMPLEMENTED/
894+
);
895+
}
893896
},
894897
};
895898

0 commit comments

Comments
 (0)