You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What other test frameworks are out there for the test runner?
Is there a list somewhere?
I ask because I used the write-your-own docs to alter one I made some years ago for doing browser testing to work with @web/test-runner.
Here's a simple of example using one of the features from the library.
Example Scenario
Let's say we've rendered a button to the screen with the innerText add svg. We want to assert it rendered and rendered with the right content.
import{test}from"@plaited/rite";test("add svg button",async(t)=>{constbody=document.querySelector("body");constbutton=awaitt.findByText<HTMLButtonElement>("add svg",body);t({given: "button rendered",should: "should be in dom",actual: button?.tagName,expected: "BUTTON",});t({given: "button rendered",should: "should have correct content",actual: button?.innerText,expected: "add svg",});});
How it works
Wether an element is in the light DOM or deeply nested in another elements
shadow DOM we can find it using the helper t.findByText. This helper takes two
arguments:
type searchText = string | RegExp
type context = HTMLElementOptional defaults to the document
It will search the light dom of the context, then penetrate all nested shadow
DOMs in the context until it finds the first element with the Node.textContent of our searchText or return undefined.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone.
What other test frameworks are out there for the test runner?
Is there a list somewhere?
I ask because I used the write-your-own docs to alter one I made some years ago for doing browser testing to work with @web/test-runner.
Here's a simple of example using one of the features from the library.
Example Scenario
Let's say we've rendered a button to the screen with the innerText
add svg
. We want to assert it rendered and rendered with the right content.How it works
Wether an element is in the light DOM or deeply nested in another elements
shadow DOM we can find it using the helper
t.findByText
. This helper takes twoarguments:
type searchText = string | RegExp
type context = HTMLElement
Optional defaults to thedocument
It will search the light dom of the
context
, then penetrate all nested shadowDOMs in the
context
until it finds the first element with theNode.textContent
of oursearchText
or return undefined.RITEway
We're using Eric Elliot's RITEway pattern. To learn more about the RITEway testing pattern read 5 questions every unit test must answer.
RITEWay forces us to answer them.
Beta Was this translation helpful? Give feedback.
All reactions