<h2 dir="auto">Scenario</h2>
<p dir="auto"><code class="notranslate">Deno.test()</code> has basically two forms currently (<code class="notranslate">1.9.0</code>):</p>
<ol dir="auto">
<li><code class="notranslate">Deno.test(&lt;name&gt;, &lt;test function&gt;)</code> and</li>
<li><code class="notranslate">Deno.test(&lt;options object&gt;)</code></li>
</ol>
<p dir="auto">Personally, I tend to write all my tests on the first form for it is generally simpler to read and write.<br>
This leaves the second form to be used only when strictly necessary (i.e to use some of the available options).</p>
<h2 dir="auto">Issue</h2>
<p dir="auto">While writing my long list of tests I often feel the need to run <em>only</em> the test being currently worked on, to have a cleaner output and lower wait time.</p>
<p dir="auto">In order to quickly mark any tests as <code class="notranslate">only</code> or <code class="notranslate">ignore</code> I have to refactor the function considerably in order to add an options object, which will just be removed after the test code is finished.</p>
<p dir="auto">I suggest reading <a href="https://github.com/denoland/deno/issues/5197" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/5197/hovercard">this discussion</a> where the issue has been pointed out before.</p>
<h2 dir="auto">Suggestion</h2>
<p dir="auto">Among the existing suggestions, I'll just add two more.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Deno.test('foobar is bahbaz', function(){
    i.like.to('move it move it');
}, 'only') // I know..."><pre class="notranslate"><span class="pl-v">Deno</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'foobar is bahbaz'</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-s1">i</span><span class="pl-kos">.</span><span class="pl-c1">like</span><span class="pl-kos">.</span><span class="pl-en">to</span><span class="pl-kos">(</span><span class="pl-s">'move it move it'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s">'only'</span><span class="pl-kos">)</span> <span class="pl-c">// I know...</span></pre></div>
<p dir="auto">Or even accept the options as the last argument too. (easier to add and remove)</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Deno.test('foobar is bahbaz', function(){
    i.like.to('move it move it');
}, { only: true });"><pre class="notranslate"><span class="pl-v">Deno</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'foobar is bahbaz'</span><span class="pl-kos">,</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-s1">i</span><span class="pl-kos">.</span><span class="pl-c1">like</span><span class="pl-kos">.</span><span class="pl-en">to</span><span class="pl-kos">(</span><span class="pl-s">'move it move it'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">only</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Currently <code class="notranslate">Deno.test</code> has two overloads:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function test(name: string, fn: () =&gt; void | Promise&lt;void&gt;): void;
function test(t: TestDefinition): void;

interface TestDefinition {
  fn: () =&gt; void | Promise&lt;void&gt;;
  name: string;
  ignore?: boolean;
  only?: boolean;
  sanitizeOps?: boolean;
  sanitizeResources?: boolean;
};"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-s1">test</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">fn</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-c1">|</span> <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
<span class="pl-k">function</span> <span class="pl-s1">test</span><span class="pl-kos">(</span><span class="pl-s1">t</span>: <span class="pl-smi">TestDefinition</span><span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

<span class="pl-k">interface</span> <span class="pl-smi">TestDefinition</span> <span class="pl-kos">{</span>
  <span class="pl-c1">fn</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-c1">|</span> <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
  <span class="pl-c1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
  <span class="pl-c1">ignore</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
  <span class="pl-c1">only</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
  <span class="pl-c1">sanitizeOps</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
  <span class="pl-c1">sanitizeResources</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">The <code class="notranslate">name</code>/<code class="notranslate">fn</code> overload is nicer for simple tests, but if we ever want to temporarily use an option like <code class="notranslate">only: true</code> we have to completely rewrite to the <code class="notranslate">TestDefinition</code> overload. If the first overload was changed to...</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function test(
  name: string,
  fn: () =&gt; void | Promise&lt;void&gt;,
  options?: TestOptions,
): void;

type TestOptions = Omit&lt;TestDefinition, &quot;name&quot; | &quot;fn&quot;&gt;;"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-s1">test</span><span class="pl-kos">(</span>
  <span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span>
  <span class="pl-s1">fn</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-c1">|</span> <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span>
  <span class="pl-s1">options</span>?: <span class="pl-smi">TestOptions</span><span class="pl-kos">,</span>
<span class="pl-kos">)</span>: <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>

<span class="pl-k">type</span> <span class="pl-smi">TestOptions</span> <span class="pl-c1">=</span> <span class="pl-smi">Omit</span><span class="pl-kos">&lt;</span><span class="pl-smi">TestDefinition</span><span class="pl-kos">,</span> <span class="pl-s">"name"</span> <span class="pl-c1">|</span> <span class="pl-s">"fn"</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">...then we could easily switch between these two calls:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Deno.test(&quot;my test&quot;, () =&gt; { assertSomething() });

Deno.test(&quot;my test&quot;, () =&gt; { assertSomething() }, { only: true });"><pre class="notranslate"><span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"my test"</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span> <span class="pl-en">assertSomething</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"my test"</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span> <span class="pl-en">assertSomething</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">only</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>