Skip to content

[Bug]: HTML reporter crashes in browser when test annotation has missing or non-string type #37771

@vladlearns

Description

@vladlearns

Version

v1.56.0

Steps to reproduce

  1. Create a test file:
import { test, expect } from '@playwright/test';

test(
  'example test with invalid annotation',
  { tag: ['@TEST-123'] },
  {
    tag: ['@TEST-123'],
    annotation: 'bug',  // should be { type: 'bug' }
    description: 'https://example.com/issues/12345',
  },
  async ({ page }) => {
    await page.goto('https://example.com');
    await expect(page).toHaveTitle(/Example/);
  }
);
  1. Run the test with HTML reporter:
npx playwright test --reporter=html
  1. Open the generated HTML report:
npx playwright show-report
  1. Check console:
Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at filter.ts:207

Expected behavior

The HTML report should always open - it should never crash at such a late in the browser regardless of what annotation data is provided
The type system should not promise type: string if the runtime doesn't enforce it

Actual behavior

  1. HTML report is generated;
  2. User opens the HTML report in a browser;
  3. React app loads and tries to filter/search tests;
  4. The getSearchValues() function is called to build search indices;
  5. It crashes on a.type.toLowerCase() when type is undefined/null.

Additional context

No response

Environment

System:
  OS: Linux 6.2 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
  CPU: (8) arm64
Binaries:
  Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
  npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
npmPackages:
  @playwright/test: 1.56.0 => 1.56.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions