Skip to content

Commit 749e90b

Browse files
committed
Suppress @actions/core output noise in tests
Mock @actions/core via a bun test preload script so the real module's stdout/stderr writes (::error::, info lines, etc.) don't clutter test output.
1 parent e49abc1 commit 749e90b

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
preload = ["./src/setup-test.ts"]

dist/index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,43 @@ var __getProtoOf = Object.getPrototypeOf;
33
var __defProp = Object.defineProperty;
44
var __getOwnPropNames = Object.getOwnPropertyNames;
55
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
function __accessProp(key) {
7+
return this[key];
8+
}
9+
var __toESMCache_node;
10+
var __toESMCache_esm;
611
var __toESM = (mod, isNodeMode, target) => {
12+
var canCache = mod != null && typeof mod === "object";
13+
if (canCache) {
14+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
15+
var cached = cache.get(mod);
16+
if (cached)
17+
return cached;
18+
}
719
target = mod != null ? __create(__getProtoOf(mod)) : {};
820
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
921
for (let key of __getOwnPropNames(mod))
1022
if (!__hasOwnProp.call(to, key))
1123
__defProp(to, key, {
12-
get: () => mod[key],
24+
get: __accessProp.bind(mod, key),
1325
enumerable: true
1426
});
27+
if (canCache)
28+
cache.set(mod, to);
1529
return to;
1630
};
1731
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
32+
var __returnValue = (v) => v;
33+
function __exportSetter(name, newValue) {
34+
this[name] = __returnValue.bind(null, newValue);
35+
}
1836
var __export = (target, all) => {
1937
for (var name in all)
2038
__defProp(target, name, {
2139
get: all[name],
2240
enumerable: true,
2341
configurable: true,
24-
set: (newValue) => all[name] = () => newValue
42+
set: __exportSetter.bind(all, name)
2543
});
2644
};
2745

@@ -3447,7 +3465,7 @@ var require_constants2 = __commonJS((exports2, module2) => {
34473465
}
34483466
})();
34493467
var channel;
3450-
var structuredClone = globalThis.structuredClone ?? function structuredClone(value, options = undefined) {
3468+
var structuredClone = globalThis.structuredClone ?? function structuredClone2(value, options = undefined) {
34513469
if (arguments.length === 0) {
34523470
throw new TypeError("missing argument");
34533471
}
@@ -16372,7 +16390,7 @@ var require_undici = __commonJS((exports2, module2) => {
1637216390
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
1637316391
if (util.nodeMajor > 16 || util.nodeMajor === 16 && util.nodeMinor >= 8) {
1637416392
let fetchImpl = null;
16375-
module2.exports.fetch = async function fetch(resource) {
16393+
module2.exports.fetch = async function fetch2(resource) {
1637616394
if (!fetchImpl) {
1637716395
fetchImpl = require_fetch().fetch;
1637816396
}
@@ -22708,11 +22726,11 @@ var require_github = __commonJS((exports2) => {
2270822726
});
2270922727

2271022728
// src/index.ts
22711-
var core2 = __toESM(require_core());
22712-
var github = __toESM(require_github());
22729+
var core2 = __toESM(require_core(), 1);
22730+
var github = __toESM(require_github(), 1);
2271322731

2271422732
// src/action.ts
22715-
var core = __toESM(require_core());
22733+
var core = __toESM(require_core(), 1);
2271622734

2271722735
class CoderAgentChatAction {
2271822736
coder;

src/setup-test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { mock } from "bun:test";
2+
3+
// Suppress @actions/core output during tests. The real module
4+
// writes GitHub Actions command format to stdout/stderr which
5+
// clutters test output with lines like "::error::..." and
6+
// "Looking up Coder user by GitHub user ID: ...".
7+
mock.module("@actions/core", () => ({
8+
info: () => {},
9+
debug: () => {},
10+
error: () => {},
11+
warning: () => {},
12+
setFailed: () => {},
13+
setOutput: () => {},
14+
getInput: () => "",
15+
getBooleanInput: () => false,
16+
}));

0 commit comments

Comments
 (0)