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.

1 Answer 1

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/[email protected]"; 
  console.log(getByRole)
</script>

Sign up to request clarification or add additional context in comments.

2 Comments

I wonder if there's a version I can copy and paste into my console. the goal is to use it here: github.com/lsoares/selenium-testing-library
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... :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.