kibana/packages/kbn-test-subj-selector
Tiago Costa e41569b4a6
fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463)
* chore(NA): remove overrides for rootDir on packages

* chore(NA): replace './target_types' with 'target_types' on packages

* chore(NA): removes stripInternal false configs

* chore(NA): remove unused strip internals
2022-11-03 01:04:55 +00:00
..
BUILD.bazel [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
index.ts modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
jest.config.js modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
kibana.jsonc modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
package.json [auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
README.mdx modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
test_subj_selector.test.ts modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
test_subj_selector.ts modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
tsconfig.json fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463) 2022-11-03 01:04:55 +00:00

---
id: kibDevDocsOpsTestSubjSelector
slug: /kibana-dev-docs/ops/test-subj-selector
title: "@kbn/test-subj-selector"
description: An utility package to quickly get css selectors from strings
date: 2022-05-19
tags: ['kibana', 'dev', 'contributor', 'operations', 'test', 'subj', 'selector']
---

Converts a testSubject selector into a CSS selector.

testSubject selector syntax rules:

  - `data-test-subj` values can include spaces

  - prefixing a value with `~` will allow matching a single word in a `data-test-subj` that uses several space delimited list words
    - example: `~foo`
    - css equivalent: `[data-test-subj~="foo"]`

  - the `>` character is used between two values to indicate that the value on the right must match an element inside an element matched by the value on the left
    - example: `foo > bar`
    - css equivalent: `[data-test-subj=foo] [data-test-subj=bar]`

  - the `&` character is used between two values to indicate that the value on both sides must both match the element
    - example: `foo & bar`
    - css equivalent: `[data-test-subj=foo][data-test-subj=bar]`