char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
96879c9
main
1import { test , type TestContext , type TestOptions } from "avril:test" ; 2 3const options :TestOptions = { 4name :"options" , 5timeout :Infinity , 6only :false , 7ignore :false , 8async fn ( t ) { 9const name :string = t . name ; 10const passed :boolean = await t . step ( "nested" , async ( child ) => { 11const result :boolean = await child . step ({ name :"ignored" , ignore :true }); 12}); 13await t . step ({ 14name :"options" , 15fn :( child ) => { 16const name :string = child . name ; 17}, 18}); 19}, 20}; 21const registered :void = test ( options ); 22test ( "named" , ( t ) => { 23const context :TestContext = t ; 24}); 25test . only ( options ); 26test . only ( "named" , ( t ) => { 27const name :string = t . name ; 28}); 29test . ignore ( options ); 30test . ignore ( "ignored" ); 31test . ignore ( "ignored" , ( t ) => { 32const name :string = t . name ; 33}); 34const only :typeof test . only = test . only ; 35only ( "detached" , () => {}); 36 37// @ts-expect-error The name form requires a callback. 38test ( "missing" ); 39// @ts-expect-error The focused name form requires a callback. 40test . only ( "missing" ); 41// @ts-expect-error Registration needs a name or options. 42test (); 43// @ts-expect-error Callbacks cannot return arbitrary promises. 44test ( "wrong result" , async () => 42 ); 45// @ts-expect-error Options retain their numeric timeout. 46test ({ name :"wrong timeout" , timeout :"100" }); 47// @ts-expect-error Registration is not asynchronous. 48const promise :Promise < void > = test ( "synchronous registration" , () => {}); 49// @ts-expect-error The internal runner is not a public export. 50import { runTests } from "avril:test" ; 51// @ts-expect-error Private extension modules are absent from the public graph. 52import { op_test_event } from "ext:core/ops" ; 53 54test ( "steps" , async ( t ) => { 55// @ts-expect-error Context names are readonly. 56t . name = "changed" ; 57// @ts-expect-error The name form requires a callback. 58t . step ( "missing" ); 59// @ts-expect-error Steps do not accept test timeouts. 60t . step ({ name :"timeout" , timeout :10 }); 61// @ts-expect-error Steps cannot be focused. 62t . step ({ name :"focused" , only :true }); 63// @ts-expect-error Steps resolve a boolean, not a string. 64const result :string = await t . step ( "result" , () => {}); 65await t . step ( "nested" , ( child ) => { 66// @ts-expect-error Nested step contexts have the same readonly name. 67child . name = "changed" ; 68}); 69});