subcases.spec.ts (1072B)
1 export const description = 'Tests with subcases'; 2 3 import { makeTestGroup } from '../common/framework/test_group.js'; 4 import { UnitTest } from '../unittests/unit_test.js'; 5 6 export const g = makeTestGroup(UnitTest); 7 8 g.test('skip') 9 .paramsSubcasesOnly(u => u.combine('y', [1, 2])) 10 .fn(t => { 11 t.skip('I skip!'); 12 }); 13 14 g.test('pass_warn_fail_skip') 15 .params(u => 16 u 17 .combine('x', [0, 1, 2, 3]) // 18 .beginSubcases() 19 .combine('y', [1, 2, 3]) 20 ) 21 .fn(t => { 22 const { x, y } = t.params; 23 if (x + y >= 5) { 24 t.fail('I fail!'); 25 } else if (x + y >= 4) { 26 t.warn('I warn!'); 27 } 28 if (x + y === 1 || x + y === 6) { 29 t.skip('I skip!'); 30 } 31 }); 32 33 g.test('DOMException,cases') 34 .params(u => u.combine('fail', [false, true])) 35 .fn(t => { 36 if (t.params.fail) { 37 throw new DOMException('Message!', 'Name!'); 38 } 39 }); 40 41 g.test('DOMException,subcases') 42 .paramsSubcasesOnly(u => u.combine('fail', [false, true])) 43 .fn(t => { 44 if (t.params.fail) { 45 throw new DOMException('Message!', 'Name!'); 46 } 47 });