0

I was trying to do something similar to the Testing Playground but I don't know which JavaScript file to include to have access to all the Testing Library native functions.

The goal is to be able to run queries like getAllByRole in the browser console. I don't want to have a Node project running. I just want a basic HTML file that includes the Testing Library JavaScript file so I can run its functions in the browser console.

Luís Soares
  • 5,726
  • 4
  • 39
  • 66

1 Answers1

1

To start without any bundle tools, try the @testing-library/dom library from the skypack CDN which prepares npm packages for native JavaScript ES6 import usage. (It's the one being used in codepen.io)

<script type="module">
  import { getByRole } from "https://cdn.skypack.dev/@testing-library/dom@7.29.6"; 
  console.log(getByRole)
</script>
lastr2d2
  • 3,604
  • 2
  • 22
  • 37
  • I wonder if there's a version I can copy and paste into my console. the goal is to use it here: https://github.com/lsoares/selenium-testing-library – Luís Soares Oct 23 '22 at 20:26
  • for the purpose above, I can't use any URLs to import (or I bump into CSP issues). I managed to put it working with a script version from the Testing Playground Chrome plugin... but apparently, it's old... :( – Luís Soares Oct 23 '22 at 20:28