oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.49k stars 2.79k forks source link

ignored tests #15488

Open bncszb opened 2 days ago

bncszb commented 2 days ago

What version of Bun is running?

1.1.37+8ca0eb831

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

bun test src

output:

bun test v1.1.37 (8ca0eb83)

src/custom-form/process-custom-form.test.ts:
✓ processCustomForm > Eye pain [6.93ms]
✓ processCustomForm > Awareness [0.80ms]

src/progress-note/categorization.test.ts:

src/lab-order/process-lab-order.test.ts:

src/adapters/langchain.test.ts:
✓ categorizeProgressNote > Fall event [55.15ms]
✓ processLabOrder > From the second of October to the fourteenth, do a lipid panel every morning. [13.58ms]
✓ embedding > Returns correct shape [1.09ms]

src/other-order/process-other-order.test.ts:

src/medication-order/process-medication-order.test.ts:

 5 pass
 0 fail
 21 expect() calls
Ran 5 tests across 6 files. [496.00ms]

bun test src/medication-order

output:

bun test v1.1.37 (8ca0eb83)

src/medication-order/process-medication-order.test.ts:
✓ processMedicationOrder > Lisinopril for hypertension [81.44ms]
✓ processMedicationOrder > Amoxicillin for bacterial sinusitis [18.34ms]

 2 pass
 0 fail
 26 expect() calls
Ran 2 tests across 1 files. [311.00ms]

What is the expected behavior?

i would expect bun to find the medication order tests as well, however they are not run i tried it with failing tests as well, they wouldn't fail in the first scenario

What do you see instead?

some tests are just skipped

Additional information

all tests are created the same way, using these helper functions:

import { Message } from "@bufbuild/protobuf";
import { describe, expect, test } from "bun:test";

export type EndpointExpectation = {
  path: string;
  matchAnd?: (RegExp | string | boolean | number)[];
  matchOr?: (RegExp | string | boolean | number)[];
};

export type EndpointTestCase = {
  name: string;
  input: Message;
  expectations: EndpointExpectation[];
};

function getMessageValue(message: Message, path: string): any {
  let value = message;

  for (const element of path.split(".")) {
    if (!isNaN(Number(element))) {
      value = value[Number(element)];
    } else {
      value = value[element];
    }
  }
  return value;
}

export function getEndpointTests(endpointFunction: CallableFunction, testCases: EndpointTestCase[]) {
  const endpointTests = describe(endpointFunction.name, () => {
    testCases.forEach((testCase) => {
      const { name, input, expectations } = testCase;
      test(name, async () => {
        const result = await endpointFunction(input);
        expectations.forEach((expectation) => {
          const { path, matchAnd, matchOr } = expectation;
          const value = getMessageValue(result, path);
          if (matchOr) {
            expect(matchOr.some((m) => (m instanceof RegExp ? value.match(m) : value === m))).toBeTruthy();
          }
          if (matchAnd) {
            matchAnd.forEach((m) => {
              if (m instanceof RegExp) {
                expect(value).toMatch(m);
              } else {
                expect(value).toEqual(m);
              }
            });
          }
        });
      });
    });
  });
  return endpointTests;
}
benmerckx commented 2 days ago

Previously reported in https://github.com/oven-sh/bun/issues/11660, https://github.com/oven-sh/bun/issues/7392, https://github.com/oven-sh/bun/issues/5400 and https://github.com/oven-sh/bun/issues/3965

Jarred-Sumner commented 2 days ago

Are the tests not run or are they showing up for a different file?

bncszb commented 2 days ago

Thanks for taking the time! They are not run. You can see for:

src/medication-order/process-medication-order.test.ts:

It is listed in the broader bun test src run, but nothing happens underneath. When I go one folder deeper with bun test src/medication-order it is found.