Skip to content

Conversation

@cpinn
Copy link
Contributor

@cpinn cpinn commented Jan 6, 2026

No description provided.

Copy link
Collaborator

@ibolmo ibolmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

various questions


// indicate the project name the tests will be sent to
const bt = wrapVitest(
{ test, expect, describe, afterAll },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend for users to:

import * as vitest from 'vitest';

const { describe, expect, test, ... } = wrapVitest(vitest);

simpler, less prone to error, and future proof if we add more functions to our support

metadata: { category: "math" },
tags: ["arithmetic"],
},
async ({ input, expected }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

til.. so the context is re-inserted as an argument

afterAll: vitestMethods.afterAll || (() => {}),
beforeEach: vitestMethods.beforeEach,
afterEach: vitestMethods.afterEach,
logOutputs: (outputs: Record<string, unknown>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't expect this method 🤔

score: number;
metadata?: Record<string, unknown>;
}) => {
const span = currentSpan();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if instead of these methods we just asked folks to use currentSpan?

@@ -0,0 +1,46 @@
import tsconfigPaths from "vite-tsconfig-paths";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't expect to see this file in here 🤔

return originalDescribe(suiteName, () => {
// Lazily initialize experiment context on first access
let context: ExperimentContext | null = null;
const getOrCreateContext = (): ExperimentContext => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like we want to extract and use the same getOrCreate inside of test() calls

"Braintrust: vitestMethods.describe is required. Please pass in the describe function from vitest.",
);
}
if (!vitestMethods.expect) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't see a wrapExpect in wrapper.ts. I wonder if each expect is a scorer?

});

// If test function returns a value, log it as output
if (testResult !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think if you traced(maybeFn || configOrFn, ...) you may have gotten this automatically?

scores: {
pass: 0,
},
metadata: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably just throw again. the traced() call should handle the error.

datasetExamples: Map<string, string>; // test name -> example id
}

// Global context holder (one per describe block)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens with concurrent calls i.e.

it.concurrent(
 describe(..., () => {
 })
);

it.concurrent(
 describe(..., () => {
 })
);

did you give currentExperiment a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants