Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

mischievousUser.test.ts 930 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  1. import { describe, expect, it } from '@jest/globals';
  2. import { addMischievousUser } from '../../../src/redteam/strategies/mischievousUser';
  3. import type { TestCase } from '../../../src/types';
  4. describe('Mischievous User Strategy', () => {
  5. it('should add mischievous user configuration to test cases', () => {
  6. const testCases: TestCase[] = [
  7. {
  8. vars: { instructions: 'hi' },
  9. assert: [{ type: 'contains', metric: 'exactMatch', value: 'expected' }],
  10. },
  11. ];
  12. const result = addMischievousUser(testCases, 'instructions', { maxTurns: 3 });
  13. expect(result).toHaveLength(1);
  14. expect(result[0].provider).toEqual({
  15. id: 'promptfoo:redteam:mischievous-user',
  16. config: { injectVar: 'instructions', maxTurns: 3 },
  17. });
  18. expect(result[0].assert?.[0].metric).toBe('exactMatch/MischievousUser');
  19. expect(result[0].metadata).toEqual({ strategyId: 'mischievous-user' });
  20. });
  21. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...