Giter Site home page Giter Site logo

tiamat-tech / testing-playground Goto Github PK

View Code? Open in Web Editor NEW

This project forked from testing-library/testing-playground

0.0 1.0 0.0 5.1 MB

🐸 Simple and complete DOM testing playground that encourage good testing practices.

Home Page: https://testing-playground.com

License: MIT License

HTML 3.86% JavaScript 90.37% CSS 5.08% Shell 0.69%

testing-playground's Introduction

Testing-Playground

test-tube

Simple and complete DOM testing playground that encourage good testing practices.

online playground | next version


All Contributors

Playground for testing-library/dom

screenshot of unimported results

Testing-Library makes it easy to get started with testing. But even then, it can still be challenging to find the right queries or to understand why an element isn't being matched.

Testing-Playground provides you with direct feedback. Trying to visualize the direct impact of adding and removing specific (aria) attributes. All to give you some visual support while learning about the importance of aria roles, labels, and attributes.

Embedding

Testing-Playground can also be embedded. There is are two embed modes. Manual integration, and oembed.

Oembed

To get started with oembed, you'll simply need to copy / paste your direct playground links into a supporting platform.

Manual integration (demo)

Follow the following steps if you wish to have an interactive playground on your website.

Add the following snippet directly before your closing </body> tag:

<script async src="https://testing-playground.com/embed.js"></script>

Create a template element, in which you add to script tags. One for html and one for javascript. Make sure to type them correctly, as that's what our embedder uses to populate the different panes.

Note that the data-testing-playground attribute is required as well.

<template data-testing-playground>
  <script type="text/html"></script>

  <script type="text/javascript"></script>
</template>

Now, you can populate the html and javascript elements:

<template data-testing-playground>
  <script type="text/html">
    <button>one</button>
  </script>

  <script type="text/javascript">
    screen.getByRole('button');
  </script>
</template>

options

To configure your playground even further, add one or more of the following attributes to your opening <template> tag. Note, don't remove the data-testing-playground attribute!

attribute type default description
data-panes [markup | preview | query | result] ['markup', 'preview', 'query', 'result'] which panes to show, and in what order
data-height number | string 300 height of the element
data-width number | string '100% ' width of the element
data-loading eager | lazy 'lazy' load the frame eager or lazy (see iframe specs)

dynamic updates

Playground can be updated using cross-window messaging after it has been loaded. After the playground is loaded, you can update it with following message: {type: 'UPDATE_DATA', markup: 'new markup', query: 'new query'} with both markup and query being optional.

To find out, if playground is ready, you can listen for a message {source: 'embedded-testing-playground', type: 'READY'} in window from which are you embedding the playground.

Example:

<template data-testing-playground data-class="messaging-iframe"></template>
<script type="text/javascript">
  function updatePlayground() {
    const iframe = document.querySelector('.messaging-iframe');
    iframe.contentWindow.postMessage(
      { type: 'UPDATE_DATA', markup: 'new markup', query: 'new query' },
      'https://testing-playground.com',
    );
  }

  window.addEventListener('message', ({ data }) => {
    if (
      data.source === 'embedded-testing-playground' &&
      data.type === 'READY'
    ) {
      updatePlayground();
    }
  });
</script>

Roadmap

Future ideas are maintained in roadmap.md. Please use the issue tracker to discuss any questions or suggestions you have.

Every section in the roadmap is accompanied by one or more issues. Contributions are most welcome!

Contributing

Please see contributing.md for more details. If you just want to run the playground on your own machine, go to your terminal and enter the following commands:

git clone [email protected]:testing-library/testing-playground.git
cd testing-playground
npm ci
npm run start

Contributors

Thanks goes to these people (emoji key):


Stephan Meijer

πŸ€” πŸ’» πŸš‡ 🚧

Marco Moretti

πŸ’» ⚠️ πŸ“–

Tim Deschryver

πŸ’»

Kent C. Dodds

πŸ€”

MichaΓ«l De Boey

πŸ’»

Bianca Del Carretto

πŸ’» πŸ“–

Gerrit Alex

πŸ’» ⚠️

Dominik Guzy

πŸ’»

ConnorProgrammes

πŸ“– πŸ’»

Jacob M-G Evans

πŸ’» ⚠️

Sumeesh Nagisetty

πŸ‘€

FlΓ‘vio H Freitas

πŸ’»

Brandon Everett

πŸ’»

Michal KočÑrek

πŸ’» πŸ€”

Alejandro Garcia Anglada

πŸ’» πŸ“– ⚠️

ddehart

πŸ’» ⚠️

Balavishnu V J

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

testing-playground's People

Contributors

aganglada avatar allcontributors[bot] avatar balavishnuvj avatar bmeverett avatar brenocota-hotmart avatar connorprogrammes avatar ddehart avatar delca85 avatar dependabot-preview[bot] avatar dependabot[bot] avatar flaviohenriquecbc avatar imgbot[bot] avatar jacobmgevans avatar ljosberinn avatar lsoares avatar lx4r avatar marcosvega91 avatar michaeldeboey avatar michal-kocarek avatar siemko avatar smeijer avatar tbusillo avatar timdeschryver avatar weslleynasrocha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.