<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>GOOD Playwright Version: 1.15.0</li>
<li>BAD Playwright Version: 1.16.0</li>
<li>Operating System: macOS</li>
<li>Extra: Node.js v16.15.0</li>
</ul>
<p dir="auto"><strong>Code Snippet</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { expect, test } from '@playwright/test';

test('toHaveJSProperty', async ({ page }) =&gt; {
  await page.setContent('&lt;video muted /&gt;');

  const video = page.locator('video');

  await expect(video).toHaveJSProperty('muted', true); // ✅ passed
  await video.evaluate&lt;unknown, HTMLVideoElement&gt;((node) =&gt; (node.muted = false));
  await expect(video).toHaveJSProperty('muted', false); // ❌ failed
});"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">expect</span><span class="pl-kos">,</span> <span class="pl-s1">test</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'toHaveJSProperty'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">setContent</span><span class="pl-kos">(</span><span class="pl-s">'&lt;video muted /&gt;'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">const</span> <span class="pl-s1">video</span> <span class="pl-c1">=</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'video'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">video</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveJSProperty</span><span class="pl-kos">(</span><span class="pl-s">'muted'</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// ✅ passed</span>
  <span class="pl-k">await</span> <span class="pl-s1">video</span><span class="pl-kos">.</span><span class="pl-c1">evaluate</span><span class="pl-kos">&lt;</span><span class="pl-smi">unknown</span><span class="pl-kos">,</span> <span class="pl-smi">HTMLVideoElement</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">node</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">(</span><span class="pl-s1">node</span><span class="pl-kos">.</span><span class="pl-c1">muted</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">video</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveJSProperty</span><span class="pl-kos">(</span><span class="pl-s">'muted'</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// ❌ failed</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">The second assertion shows "expect.toHaveJSProperty: expectedValue: expected object, got boolean".</p>
<p dir="auto">But if I change it to <code class="notranslate">expect(video).toHaveJSProperty('muted', {})</code>,<br>
the error became:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    Error: expect(received).toHaveJSProperty(expected) // deep equality

    Expected: {}
    Received: false"><pre class="notranslate"><code class="notranslate">    Error: expect(received).toHaveJSProperty(expected) // deep equality

    Expected: {}
    Received: false
</code></pre></div>
<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>Playwright Version: 1.21.1 And <a href="mailto:playwright-internal@1.22.0-next">playwright-internal@1.22.0-next</a></li>
<li>Operating System: Mac</li>
<li>Node.js version: v16.15.0</li>
<li>Browser: All</li>
<li>Extra: -</li>
</ul>


<p dir="auto">When pass false as expected value of toHaveJSProperty,<br>
Playwright throws <code class="notranslate">expect.toHaveJSProperty: expectedValue: expected object, got boolean</code> error.</p>
<p dir="auto"><strong>Code Snippet</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// This test is pass
test('pass true to toHaveJSProperty', async ({ page }) =&gt; {
  await page.setContent('&lt;div&gt;&lt;/div&gt;');
  await page.$eval('div', e =&gt; e.foo = true);
  const locator = page.locator('div');

  // Pass true as expected value
  await expect(locator).toHaveJSProperty('foo', true);
});

// But this test is failed
test('pass false to toHaveJSProperty', async ({ page }) =&gt; {
  await page.setContent('&lt;div&gt;&lt;/div&gt;');
  await page.$eval('div', e =&gt; e.foo = false);
  const locator = page.locator('div');

  // Pass false as expected value
  await expect(locator).toHaveJSProperty('foo', false);
});"><pre class="notranslate"><span class="pl-c">// This test is pass</span>
<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'pass true to toHaveJSProperty'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">setContent</span><span class="pl-kos">(</span><span class="pl-s">'&lt;div&gt;&lt;/div&gt;'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">$eval</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">,</span> <span class="pl-s1">e</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-s1">locator</span> <span class="pl-c1">=</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-c">// Pass true as expected value</span>
  <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">locator</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveJSProperty</span><span class="pl-kos">(</span><span class="pl-s">'foo'</span><span class="pl-kos">,</span> <span class="pl-c1">true</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-c">// But this test is failed</span>
<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'pass false to toHaveJSProperty'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">setContent</span><span class="pl-kos">(</span><span class="pl-s">'&lt;div&gt;&lt;/div&gt;'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">$eval</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">,</span> <span class="pl-s1">e</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">foo</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</span> <span class="pl-s1">locator</span> <span class="pl-c1">=</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-c">// Pass false as expected value</span>
  <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">locator</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveJSProperty</span><span class="pl-kos">(</span><span class="pl-s">'foo'</span><span class="pl-kos">,</span> <span class="pl-c1">false</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></pre></div>
<p dir="auto">I got below error when run "pass false to toHaveJSProperty" test.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  1) [playwright-test] › playwright.expect.misc.spec.ts:187:1 › pass boolean as false ==============

    expect.toHaveJSProperty: expectedValue: expected object, got boolean

      189 |   await page.$eval('div', e =&gt; e.foo = false);
      190 |   const locator = page.locator('div');
    &gt; 191 |   await expect(locator).toHaveJSProperty('foo', false);
          |                         ^
      192 | });"><pre class="notranslate"><code class="notranslate">  1) [playwright-test] › playwright.expect.misc.spec.ts:187:1 › pass boolean as false ==============

    expect.toHaveJSProperty: expectedValue: expected object, got boolean

      189 |   await page.$eval('div', e =&gt; e.foo = false);
      190 |   const locator = page.locator('div');
    &gt; 191 |   await expect(locator).toHaveJSProperty('foo', false);
          |                         ^
      192 | });
</code></pre></div>