{"record":{"id":"af60c40ddf2aa714","repo":"facebook/react","slug":"365","errorCode":"365","errorMessage":"Invalid selector type specified.","messagePattern":"Invalid selector type specified\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-reconciler/src/ReactTestSelectors.js","lineNumber":208,"sourceCode":"      break;\n    case TEST_NAME_TYPE:\n      if (\n        tag === HostComponent ||\n        tag === HostHoistable ||\n        tag === HostSingleton\n      ) {\n        const dataTestID = fiber.memoizedProps['data-testname'];\n        if (\n          typeof dataTestID === 'string' &&\n          dataTestID.toLowerCase() ===\n            (selector as any as TestNameSelector).value.toLowerCase()\n        ) {\n          return true;\n        }\n      }\n      break;\n    default:\n      throw new Error('Invalid selector type specified.');\n  }\n\n  return false;\n}\n\nfunction selectorToString(selector: Selector): string | null {\n  switch (selector.$$typeof) {\n    case COMPONENT_TYPE:\n      const displayName = getComponentNameFromType(selector.value) || 'Unknown';\n      return `<${displayName}>`;\n    case HAS_PSEUDO_CLASS_TYPE:\n      return `:has(${selectorToString(selector) || ''})`;\n    case ROLE_TYPE:\n      return `[role=\"${(selector as any as RoleSelector).value}\"]`;\n    case TEXT_TYPE:\n      return `\"${(selector as any as TextSelector).value}\"`;\n    case TEST_NAME_TYPE:\n      return `[data-testname=\"${(selector as any as TestNameSelector).value}\"]`;","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-reconciler/src/ReactTestSelectors.js#L190-L226","documentation":"matchSelector switches on selector.$$typeof and recognizes only the selector types the test-selector module defines (component, role, test name/ID, text, and the :has pseudo-class selector). Anything else falls into the default branch and throws (error code 365). In practice this means a hand-built selector object, a selector that lost its Symbol identity, or a selector created by a different React copy whose $$typeof symbols do not match the copy performing the match.","triggerScenarios":"Passing an object literal without a recognized $$typeof into findAllNodes/selector matching; passing selectors built by a second react/react-reconciler instance whose TEST_NAME_TYPE/ROLE_TYPE symbols differ from the one matching; selectors that survived JSON round-tripping (Symbols are lost).","commonSituations":"Duplicate react packages in a bundle where one builds the selector and another matches it; serialized test fixtures of selectors; hand-rolled selector objects copied from an older React version's shape.","solutions":["Build selectors only with the provided factories: createTestNameSelector, createComponentSelector, createRoleSelector, createTextSelector, createHasPseudoClassSelector","Dedupe react so the creator and the matcher share one copy and its symbols (npm ls react)","Never hand-write, cache across builds, or JSON-serialize selector objects — construct them at query time"],"exampleFix":"// before\nfindAllNodes(root, [{$$typeof: Symbol.for('react.test_name'), value: 'feed'}]); // hand-built\n\n// after\nimport {createTestNameSelector} from 'react-reconciler'; // same React copy as the matcher\nfindAllNodes(root, [createTestNameSelector('feed')]);","handlingStrategy":"type-guard","validationCode":"// always construct selectors through the factories of the same React copy\nimport {createTestNameSelector} from '.../test-selectors';\nconst selectors = [createTestNameSelector('feed')];\nfindAllNodes(root, selectors);","typeGuard":"const KNOWN_SELECTOR_TYPES = new Set([\n  COMPONENT_TYPE,\n  ROLE_TYPE,\n  TEST_NAME_TYPE,\n  TEXT_TYPE,\n  HAS_PSEUDO_CLASS_TYPE,\n]); // import the TYPE constants from the same React copy that will match\nconst isValidSelector = (s) =>\n  s != null && typeof s === 'object' && KNOWN_SELECTOR_TYPES.has(s.$$typeof);","tryCatchPattern":null,"preventionTips":["Never hand-build selector objects or round-trip them through JSON (Symbols are lost)","Dedupe react so selector creation and matching share one copy's symbols","Build selectors at query time, not ahead of time across builds"],"tags":["test-selectors","selector","symbol-mismatch","duplicate-packages"],"backgroundTag":"invalid-test-selector-type","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}