Airbnb enzyme yog dab tsi?
Airbnb enzyme yog dab tsi?

Video: Airbnb enzyme yog dab tsi?

Video: Airbnb enzyme yog dab tsi?
Video: UI and Unit Testing with Airbnb's Enzyme - Ryan Walsh 2024, Kaum ib hlis
Anonim

18, 359. Los ntawm Leland Richardson. Enzyme yog JavaScript Testing utility rau React uas ua rau nws yooj yim dua rau kev lees paub, tswj xyuas, thiab hla koj cov React Components' cov zis. Nws yog tsim los ntawm Airbnb thiab tom qab ntawd hloov mus rau ib lub koom haum ywj pheej.

Tom qab ntawd, dab tsi yog qhov txawv ntawm jest thiab enzyme?

Ob leeg Jest thiab Enzyme tau tsim tshwj xeeb los kuaj cov ntawv thov React, Jest tuaj yeem siv nrog lwm yam Javascript app tab sis Enzyme tsuas yog ua haujlwm nrog React. Jest tuaj yeem siv tsis tau Enzyme rendering Cheebtsam thiab sim nrog snapshots, Enzyme tsuas ntxiv functionality ntxiv.

Dhau li saum toj no, dab tsi yog jest thiab enzyme? Jest yog javascript testing moj khaum, tsim los ntawm cov neeg tsim khoom uas tsim cov tshuaj tiv thaiv. Jest tsis txwv rau cov txheej txheem ua haujlwm, nws yog lub hom phiaj dav dav javascript testing moj khaum. tab sis raws li nws yog los ntawm react developers ntau inclination yog muaj. Enzyme yog lwm lub moj khaum uas tau tsim tshwj xeeb los kuaj cov tshuaj tiv thaiv.

Ib yam li ntawd, koj tuaj yeem nug, dab tsi yog enzyme JS?

Enzyme . Enzyme yog a JavaScript Kev ntsuas hluav taws xob rau Teb uas ua rau nws yooj yim rau kev sim koj Teb Cov khoom tsim tawm. Koj tuaj yeem tswj hwm, hla, thiab qee txoj hauv kev simulate runtime muab cov zis. Enzyme cov API yog txhais tau tias yog intuitive thiab hloov tau los ntawm kev ua raws li jQuery's API rau DOM manipulation thiab traversal.

Qhov txawv ntawm mount thiab ntiav yog dab tsi?

Ib txwm pib nrog ntiav . Yog tias componentDidMount lossis componentDidUpdate yuav tsum tau sim, siv Mount . Yog tias koj xav sim cov khoom siv lub neej thiab tus cwj pwm ntawm menyuam yaus, siv Mount . Yog tias koj xav sim cov menyuam yaus ua haujlwm nrog nyiaj siv ua haujlwm tsawg dua Mount thiab koj tsis xav nyob rau hauv txoj kev lifecycle, siv render.

Pom zoo: