---
title: "Testing Library and browser mode · vuejs.school"
description: "Find elements by role and label with Testing Library, pick between getBy, queryBy and findBy, and run the tests a simulated page cannot answer in a real browser with Vitest Browser Mode."
canonical_url: "https://vuejs.school/learn/testing/testing-library-and-browser-mode"
meta:
  "og:description": "Find elements by role and label with Testing Library, pick between getBy, queryBy and findBy, and run the tests a simulated page cannot answer in a real browser with Vitest Browser Mode."
  "og:image": "https://vuejs.school/_og/d/a_~VGVzdGluZyBMaWJyYXJ5IGFuZCBicm93c2VyIG1vZGUgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BLibrary%2Band%2Bbrowser%2Bmode%2Cdescription_~RmluZCBlbGVtZW50cyBieSByb2xlIGFuZCBsYWJlbCB3aXRoIFRlc3RpbmcgTGlicmFyeSwgcGljayBiZXR3ZWVuIGdldEJ5LCBxdWVyeUJ5IGFuZCBmaW5kQnksIGFuZCBydW4gdGhlIHRlc3RzIGEgc2ltdWxhdGVkIHBhZ2UgY2Fubm90IGFuc3dlciBpbiBhIHJlYWwgYnJvd3NlciB3aXRoIFZpdGVzdCBCcm93c2VyIE1vZGUu%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNSBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctbGlicmFyeS1hbmQtYnJvd3Nlci1tb2RlIg%2Cs_Vg4fi-NXtMk5rWjR.png"
  "og:image:alt": "Testing Library and browser mode · vuejs.school"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Testing Library and browser mode · vuejs.school"
  "twitter:image": "https://vuejs.school/_og/d/a_~VGVzdGluZyBMaWJyYXJ5IGFuZCBicm93c2VyIG1vZGUgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BLibrary%2Band%2Bbrowser%2Bmode%2Cdescription_~RmluZCBlbGVtZW50cyBieSByb2xlIGFuZCBsYWJlbCB3aXRoIFRlc3RpbmcgTGlicmFyeSwgcGljayBiZXR3ZWVuIGdldEJ5LCBxdWVyeUJ5IGFuZCBmaW5kQnksIGFuZCBydW4gdGhlIHRlc3RzIGEgc2ltdWxhdGVkIHBhZ2UgY2Fubm90IGFuc3dlciBpbiBhIHJlYWwgYnJvd3NlciB3aXRoIFZpdGVzdCBCcm93c2VyIE1vZGUu%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNSBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctbGlicmFyeS1hbmQtYnJvd3Nlci1tb2RlIg%2Cs_Vg4fi-NXtMk5rWjR.png"
  "twitter:image:alt": "Testing Library and browser mode · vuejs.school"
---

> Index of every page on this site: [llms.txt](https://vuejs.school/llms.txt)

# **Testing Library and browser mode**

Find elements by role and label with Testing Library, pick between getBy, queryBy and findBy, and run the tests a simulated page cannot answer in a real browser with Vitest Browser Mode.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://vuejs.school/#website","@type":"WebSite","description":"A free AI-instructed school for Vue.js. Short tutorials, runnable code and quizzes that adapt to you.","name":"vuejs.school","url":"https://vuejs.school/","publisher":{"@id":"https://vuejs.school/#identity"}},{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#webpage","@type":"WebPage","description":"Find elements by role and label with Testing Library, pick between getBy, queryBy and findBy, and run the tests a simulated page cannot answer in a real browser with Vitest Browser Mode.","name":"Testing Library and browser mode","url":"https://vuejs.school/learn/testing/testing-library-and-browser-mode","breadcrumb":{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#breadcrumb"},"isPartOf":{"@id":"https://vuejs.school/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://vuejs.school/learn/testing/testing-library-and-browser-mode"]}],"primaryImageOfPage":{"@id":"https://vuejs.school/#logo"}},{"@id":"https://vuejs.school/#identity","@type":"Organization","description":"A free AI-instructed school for Vue.js. Short tutorials, runnable code and quizzes that adapt to you.","name":"vuejs.school","url":"https://vuejs.school","logo":{"@id":"https://vuejs.school/#logo"}},{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#article","description":"Find elements by role and label with Testing Library, pick between getBy, queryBy and findBy, and run the tests a simulated page cannot answer in a real browser with Vitest Browser Mode.","headline":"Testing Library and browser mode","inLanguage":"en","isAccessibleForFree":true,"thumbnailUrl":"https://vuejs.school/_og/d/a_~VGVzdGluZyBMaWJyYXJ5IGFuZCBicm93c2VyIG1vZGUgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BLibrary%2Band%2Bbrowser%2Bmode%2Cdescription_~RmluZCBlbGVtZW50cyBieSByb2xlIGFuZCBsYWJlbCB3aXRoIFRlc3RpbmcgTGlicmFyeSwgcGljayBiZXR3ZWVuIGdldEJ5LCBxdWVyeUJ5IGFuZCBmaW5kQnksIGFuZCBydW4gdGhlIHRlc3RzIGEgc2ltdWxhdGVkIHBhZ2UgY2Fubm90IGFuc3dlciBpbiBhIHJlYWwgYnJvd3NlciB3aXRoIFZpdGVzdCBCcm93c2VyIE1vZGUu%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNSBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctbGlicmFyeS1hbmQtYnJvd3Nlci1tb2RlIg%2Cs_Vg4fi-NXtMk5rWjR.png","@type":["Article","TechArticle"],"articleSection":["Testing"],"author":{"@id":"https://vuejs.school/#identity"},"image":{"@id":"https://vuejs.school/#/schema/image/1"},"isPartOf":{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#webpage"},"keywords":["getByRole()","queryBy and findBy","user-event","vitest-browser-vue","expect.element()"],"mainEntityOfPage":{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#webpage"},"publisher":{"@id":"https://vuejs.school/#identity"}},{"@id":"https://vuejs.school/learn/testing/testing-library-and-browser-mode#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Skill tree","item":"https://vuejs.school/track","position":1},{"@type":"ListItem","name":"Testing","item":"https://vuejs.school/track/testing","position":2},{"@type":"ListItem","name":"Testing Library and browser mode","position":3}]},{"@id":"https://vuejs.school/#logo","@type":"ImageObject","caption":"vuejs.school","contentUrl":"https://vuejs.school/apple-touch-icon.png","inLanguage":"en","url":"https://vuejs.school/apple-touch-icon.png"},{"@id":"https://vuejs.school/#/schema/image/1","@type":"ImageObject","contentUrl":"https://vuejs.school/_og/d/a_~VGVzdGluZyBMaWJyYXJ5IGFuZCBicm93c2VyIG1vZGUgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BLibrary%2Band%2Bbrowser%2Bmode%2Cdescription_~RmluZCBlbGVtZW50cyBieSByb2xlIGFuZCBsYWJlbCB3aXRoIFRlc3RpbmcgTGlicmFyeSwgcGljayBiZXR3ZWVuIGdldEJ5LCBxdWVyeUJ5IGFuZCBmaW5kQnksIGFuZCBydW4gdGhlIHRlc3RzIGEgc2ltdWxhdGVkIHBhZ2UgY2Fubm90IGFuc3dlciBpbiBhIHJlYWwgYnJvd3NlciB3aXRoIFZpdGVzdCBCcm93c2VyIE1vZGUu%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNSBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctbGlicmFyeS1hbmQtYnJvd3Nlci1tb2RlIg%2Cs_Vg4fi-NXtMk5rWjR.png","inLanguage":"en","url":"https://vuejs.school/_og/d/a_~VGVzdGluZyBMaWJyYXJ5IGFuZCBicm93c2VyIG1vZGUgwrcgdnVlanMuc2Nob29s%2Cc_OgCard.takumi%2Ctitle_Testing%2BLibrary%2Band%2Bbrowser%2Bmode%2Cdescription_~RmluZCBlbGVtZW50cyBieSByb2xlIGFuZCBsYWJlbCB3aXRoIFRlc3RpbmcgTGlicmFyeSwgcGljayBiZXR3ZWVuIGdldEJ5LCBxdWVyeUJ5IGFuZCBmaW5kQnksIGFuZCBydW4gdGhlIHRlc3RzIGEgc2ltdWxhdGVkIHBhZ2UgY2Fubm90IGFuc3dlciBpbiBhIHJlYWwgYnJvd3NlciB3aXRoIFZpdGVzdCBCcm93c2VyIE1vZGUu%2Ceyebrow_~VGVzdGluZyDCtyBMZXNzb24gNSBvZiA3%2Ctint_mint%2Cp_Ii9sZWFybi90ZXN0aW5nL3Rlc3RpbmctbGlicmFyeS1hbmQtYnJvd3Nlci1tb2RlIg%2Cs_Vg4fi-NXtMk5rWjR.png"}]}
```