[ad_1]
I am so excited in regards to the reaction to my new
Checking out JavaScript path! I knew the developer
neighborhood wanted lend a hand with trying out the suitable method, however… wow. I am floored. 🙏
However when you have not signed up but (or although you could have), let’s discuss React
for a minute.
If you happen to’ve been following me for some time, I am beautiful thinking about
React. I am most efficient with React, and I do not use some other frameworks to
get paintings executed at the frontend.
However I am additionally a large fan of averting trying out implementation main points, and React
is an implementation element!!
Bet what that suggests? The entire stuff we discuss in
TestingJavaScript.com is rather simple to
follow with different frameworks — like whichever framework you might be the usage of at the moment,
or will use one day.
If truth be told, I’ve a whole path appearing you easy methods to stand up and operating along with your
personal trying out software and revel in the similar advantages that you can see with React
Checking out Library. That is due to the truth that React Checking out Library itself is
an excessively small library, and the actual brains at the back of it’s DOM Checking out Library
which is completely framework-agnostic! Cool proper!? 😎
If truth be told,
take a look at this case
from the path for trying out a jQuery plugin with DOM Checking out Library:
import '@testing-library/jest-dom/extend-expect'
import {getQueriesForElement} from '@testing-library/dom'
import userEvent from '@testing-library/user-event'
import $ from 'jquery'
$.fn.countify = serve as countify() {
this.html(`
<div>
<button>0</button>
</div>
`)
const $button = this.in finding('button')
$button._count = 0
$button.click on(() => {
$button._count++
$button.textual content($button._count)
})
}
// checks:
check('counter increments', () => {
const div = record.createElement('div')
$(div).countify()
const {getByText} = getQueriesForElement(div)
const counter = getByText('0')
userEvent.click on(counter)
anticipate(counter).toHaveTextContent('1')
userEvent.click on(counter)
anticipate(counter).toHaveTextContent('2')
})
The opposite frameworks are even higher, taking into consideration most present frameworks are
component-based. What is so cool is that 99% of the checks you write with those
gear will glance mainly the similar without reference to what framework you utilize! That is
an enormous win.
The toughest phase is determining easy methods to get some DOM out of your element into
the record. And probably the most path modules presentations you ways to do this with 11
frameworks and libraries! I feel you can actually like this a part of the path!
[ad_2]