Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
react Regex for value after colon in dom

I'm trying to write a test for the presence of text after a certain value in my html document:

<span>Dog facts: something</span>

I want to test for the presence of text after the pattern "Dog facts:" to not be null

It should be noted the value after Dog facts: changes so I can't assert on a specific value I just need to make sure that there exists text after the colon.

I am not sure if regex is what I want but I tried doing this:

test('renders dog facts', () => {
  render(<App />);
  const linkElement = screen.getByText(/Dog facts:/i);
  expect(linkElement).toBeInTheDocument();
});

but this always returns true no matter whats after the colon

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to only match for a letter after the dog facts you can use this.

/Dog Facts: \w/g
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!