Skip to content

Commit

Permalink
Build commit 01b222e
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Jun 1, 2024
1 parent 774b2bd commit d32b775
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions api/extension/QUnit.onUncaughtException/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="/assets/styles.css?v=4ca9bae3" media="screen">
<link rel="alternate" type="application/rss+xml" href="/feed.xml" title="QUnit">
<title>QUnit.onUncaughtException() | QUnit</title>
<meta property="og:title" content="QUnit.onUncaughtException()"><meta name="description" content="Handle a global error."><meta property="og:description" content="Handle a global error."><link rel="me" href="https://fosstodon.org/@qunit"><meta name="twitter:creator" content="@qunitjs"><meta name="twitter:site" content="@qunitjs"><meta name="twitter:card" content="summary_large_image">
<meta property="og:title" content="QUnit.onUncaughtException()"><meta name="description" content="Report a global error."><meta property="og:description" content="Report a global error."><link rel="me" href="https://fosstodon.org/@qunit"><meta name="twitter:creator" content="@qunitjs"><meta name="twitter:site" content="@qunitjs"><meta name="twitter:card" content="summary_large_image">
<body>
<header class="site-header" role="banner">
<div class="site-header-wrapper wrapper">
Expand Down Expand Up @@ -77,7 +77,7 @@ <h1>QUnit.onUncaughtException()</h1>
<h2 id="description" class="screen-reader-text h-api-desc">Description</h2>
<p><code class="language-plaintext highlighter-rouge">QUnit.onUncaughtException( error )</code></p>

<p>Handle a global error that should result in a failed test run.</p>
<p>Report a global error that should result in a failed test run.</p>

<table>
<thead>
Expand All @@ -94,16 +94,27 @@ <h2 id="description" class="screen-reader-text h-api-desc">Description</h2>
</tbody>
</table>

<p>This method can be safely called at any time, including between or outside tests. It is designed for use by plugins and integration layers.</p>

<p>In general, you should not use this method and instead throw an error. QUnit automatically finds and reports uncaught errors. The following are handled by default and should not be connected to <code class="language-plaintext highlighter-rouge">QUnit.onUncaughtException()</code> a second time:</p>

<ul>
<li>HTML Runner: <code class="language-plaintext highlighter-rouge">window.onerror</code></li>
<li>HTML Runner: <code class="language-plaintext highlighter-rouge">window.addEventListener('unhandledrejection', …)</code></li>
<li>QUnit CLI: <code class="language-plaintext highlighter-rouge">process.on('unhandledRejection', …)</code></li>
<li>QUnit CLI: <code class="language-plaintext highlighter-rouge">process.on('uncaughtException', …)</code></li>
</ul>

<h2 id="examples">Examples</h2>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">const</span> <span class="nx">error</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Failed to reverse the polarity of the neutron flow</span><span class="dl">'</span><span class="p">);</span>
<span class="nx">QUnit</span><span class="p">.</span><span class="nf">onUncaughtException</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
</code></pre></div></div>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">process</span><span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="dl">'</span><span class="s1">uncaughtException</span><span class="dl">'</span><span class="p">,</span> <span class="nx">QUnit</span><span class="p">.</span><span class="nx">onUncaughtException</span><span class="p">);</span>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">process</span><span class="p">.</span><span class="nf">on</span><span class="p">(</span><span class="dl">'</span><span class="s1">unhandledExample</span><span class="dl">'</span><span class="p">,</span> <span class="nx">QUnit</span><span class="p">.</span><span class="nx">onUncaughtException</span><span class="p">);</span>
</code></pre></div></div>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">window</span><span class="p">.</span><span class="nf">addEventListener</span><span class="p">(</span><span class="dl">'</span><span class="s1">unhandledrejection</span><span class="dl">'</span><span class="p">,</span> <span class="nf">function </span><span class="p">(</span><span class="nx">event</span><span class="p">)</span> <span class="p">{</span>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">window</span><span class="p">.</span><span class="nf">addEventListener</span><span class="p">(</span><span class="dl">'</span><span class="s1">unhandledexample</span><span class="dl">'</span><span class="p">,</span> <span class="nf">function </span><span class="p">(</span><span class="nx">event</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">QUnit</span><span class="p">.</span><span class="nf">onUncaughtException</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">reason</span><span class="p">);</span>
<span class="p">});</span>
</code></pre></div></div>
Expand Down
2 changes: 1 addition & 1 deletion api/extension/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h2 id="qunit-hooks"><a href="/api/QUnit/hooks/">QUnit.hooks</a></h2>
<p>Add global callbacks to run before or after each test.</p>

<h2 id="qunit-onuncaughtexception"><a href="/api/extension/QUnit.onUncaughtException/">QUnit.onUncaughtException()</a></h2>
<p>Handle a global error.</p>
<p>Report a global error.</p>

<h2 id="qunit-stack"><a href="/api/extension/QUnit.stack/">QUnit.stack()</a></h2>
<p>Return a single line string representing the stacktrace.</p>
Expand Down
2 changes: 1 addition & 1 deletion feed.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="https://qunitjs.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://qunitjs.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2024-05-31T18:39:58+00:00</updated><id>https://qunitjs.com/feed.xml</id><title type="html">QUnit</title><subtitle>The powerful, easy-to-use JavaScript testing framework.</subtitle></feed>
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.3.3">Jekyll</generator><link href="https://qunitjs.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://qunitjs.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2024-06-01T00:34:30+00:00</updated><id>https://qunitjs.com/feed.xml</id><title type="html">QUnit</title><subtitle>The powerful, easy-to-use JavaScript testing framework.</subtitle></feed>

0 comments on commit d32b775

Please sign in to comment.