Skip to content

Commit befee31

Browse files
nicohrubecclaude
andcommitted
test(mistral): Run the suite ESM-only
`@mistralai/mistralai` v2 ships no CJS build, so CJS consumers load it via `require(esm)`, whose auto-instrumentation is inconsistent across Node versions (works on 24/26, fails on 22). The SDK's native mode is ESM, so use `createEsmTests` and cover it there only. Also give the embeddings mock a distinct id per call shape so the single-input span is targeted unambiguously. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 962495d commit befee31

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎dev-packages/node-integration-tests/suites/tracing/mistral/scenario-embeddings.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ function startMockServer() {
77
app.use(express.json());
88

99
app.post('/v1/embeddings', (req, res) => {
10-
const { model } = req.body;
10+
const { model, inputs } = req.body;
1111

1212
if (model === 'error-model') {
1313
res.status(404).set('x-request-id', 'mock-request-123').end('Model not found');
1414
return;
1515
}
1616

17+
// Distinct id per call shape so tests can target the single-input span unambiguously.
1718
res.send({
18-
id: 'embd-mock123',
19+
id: Array.isArray(inputs) ? 'embd-mock-multi' : 'embd-mock123',
1920
object: 'list',
2021
model,
2122
data: [{ object: 'embedding', embedding: [0.1, 0.2, 0.3], index: 0 }],

‎dev-packages/node-integration-tests/suites/tracing/mistral/test.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ import {
1919
GEN_AI_USAGE_TOTAL_TOKENS,
2020
} from '@sentry/conventions/attributes';
2121
import { afterAll, describe, expect } from 'vitest';
22-
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
22+
import { cleanupChildProcesses, createEsmTests } from '../../../utils/runner';
2323

2424
const PROVIDER = 'mistral';
2525
const ORIGIN = 'auto.ai.mistral';
2626

27+
// ESM-only: `@mistralai/mistralai` v2 ships no CJS build, so CJS consumers load it via `require(esm)`,
28+
// whose auto-instrumentation is inconsistent across Node versions. The SDK's native mode is ESM, so we
29+
// only run the suite there.
2730
describe('Mistral integration', () => {
2831
afterAll(() => {
2932
cleanupChildProcesses();
3033
});
3134

32-
createEsmAndCjsTests(__dirname, 'scenario-chat.mjs', 'instrument.mjs', (createRunner, test) => {
35+
createEsmTests(__dirname, 'scenario-chat.mjs', 'instrument.mjs', (createRunner, test) => {
3336
test('creates chat spans with genAI recording disabled', async () => {
3437
await createRunner()
3538
.expect({
@@ -69,7 +72,7 @@ describe('Mistral integration', () => {
6972
});
7073
});
7174

72-
createEsmAndCjsTests(__dirname, 'scenario-chat.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
75+
createEsmTests(__dirname, 'scenario-chat.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
7376
test('records chat inputs and outputs with PII enabled', async () => {
7477
await createRunner()
7578
.expect({
@@ -89,7 +92,7 @@ describe('Mistral integration', () => {
8992
});
9093
});
9194

92-
createEsmAndCjsTests(__dirname, 'scenario-chat.mjs', 'instrument-with-options.mjs', (createRunner, test) => {
95+
createEsmTests(__dirname, 'scenario-chat.mjs', 'instrument-with-options.mjs', (createRunner, test) => {
9396
test('records chat inputs and outputs with explicit integration options', async () => {
9497
await createRunner()
9598
.expect({
@@ -105,7 +108,7 @@ describe('Mistral integration', () => {
105108
});
106109
});
107110

108-
createEsmAndCjsTests(__dirname, 'scenario-embeddings.mjs', 'instrument.mjs', (createRunner, test) => {
111+
createEsmTests(__dirname, 'scenario-embeddings.mjs', 'instrument.mjs', (createRunner, test) => {
109112
test('creates embeddings spans', async () => {
110113
await createRunner()
111114
.expect({
@@ -131,7 +134,7 @@ describe('Mistral integration', () => {
131134
});
132135
});
133136

134-
createEsmAndCjsTests(__dirname, 'scenario-embeddings.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
137+
createEsmTests(__dirname, 'scenario-embeddings.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
135138
test('records embeddings input with PII enabled', async () => {
136139
await createRunner()
137140
.expect({
@@ -148,7 +151,7 @@ describe('Mistral integration', () => {
148151
});
149152
});
150153

151-
createEsmAndCjsTests(__dirname, 'scenario-agents.mjs', 'instrument.mjs', (createRunner, test) => {
154+
createEsmTests(__dirname, 'scenario-agents.mjs', 'instrument.mjs', (createRunner, test) => {
152155
test('creates invoke_agent spans', async () => {
153156
await createRunner()
154157
.expect({
@@ -179,7 +182,7 @@ describe('Mistral integration', () => {
179182
});
180183
});
181184

182-
createEsmAndCjsTests(__dirname, 'scenario-agents.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
185+
createEsmTests(__dirname, 'scenario-agents.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
183186
test('records agent inputs and outputs with PII enabled', async () => {
184187
await createRunner()
185188
.expect({

0 commit comments

Comments
 (0)