Unit Testing - Stencil.js
文章推薦指數: 80 %
Stencil makes it easy to unit test components and app utility functions using Jest. Unit tests validate the code in isolation. Well written tests are fast, ...
DocsResourcesBlogEnterpriseEnglish日本語IntroductionOverviewGoalsandObjectivesGettingStartedMyFirstComponentComponentsAPIComponentLifecycleMethodsPropertiesInternalStateReactiveDataUsingJSXEventsMethodsHostElementStylingFunctionalComponentsFrameworkIntegrationsOverviewBindingsAngularReactVueEmberJavaScriptStaticSiteGenerationOverviewPrerenderConfigBasicsDebuggingMetatagsServerSideRenderingDeploymentConfigOverviewDevServerPluginsExtrasCLIOutputTargetsOverviewdistdist-custom-elementsdist-custom-elements-bundlewwwstatsdocs-readmedocs-jsondocs-customCopyTasksGuidesAssetsBundlingDesignSystemsFormsHydrateAppPublishingServiceWorkersStencilStoreStyleGuideTypedComponentsWebWorkersTestingOverviewConfigUnitTestingEnd-to-endTestingMockingVisualScreenshotDiffScreenshotConnectorCoreCompilerAPICompilerAPICLIAPIDevServerAPICommunityStencilonTwitterStencilonSlackStencilonGitHubLegalTelemetryPrivacyPolicyReferenceSupportPolicyVersioningBrowserSupportFAQUnitTesting
Stencilmakesiteasytounittestcomponentsandapputilityfunctionsusing
Jest.Unittestsvalidatethecodeinisolation.Wellwrittentestsarefast,repeatable,andeasytoreasonabout.
Torununittests,runstenciltest--spec.Filesendingin
.spec.tswillbeexecuted.
newSpecPage()
InordertounittestacomponentasrenderedHTML,testscanuse
newSpecPage()importedfrom
@stencil/core/testing.Thistestingutilitymethodissimilarto
newE2EPage(),however,
newSpecPage()ismuchfastersinceitdoesnotrequireafull
Puppeteerinstancetoberunning.Pleaseseethe
newE2EPage()docsonmoreinformationaboutcompleteEnd-to-endtestingwithPuppeteer.
BelowisasimpleexamplewherenewSpecPage()isgivenonecomponentclasswhichwasimported,andtheinitialHTMLtouseforthetest.Inthisexample,whenthecomponent
MyCmprendersitsetsitstextcontentas"Success!".Thematcher
toEqualHtml()isthenusedtoensurethecomponentrendersasexpected.
import{newSpecPage}from'@stencil/core/testing';
import{MyCmp}from'../my-cmp';
it('shouldrendermycomponent',async()=>{
constpage=awaitnewSpecPage({
components:[MyCmp],
html:`
延伸文章資訊
- 1Stencil Test的应用总结
Stencil值的测试很简单——从Stencil Buffer 里读出该像素的Stencil值(8bit的UINT)与参考值比较,满足比较条件则pass最终画出(假设能通过Depth Test或...
- 2OpenGL基礎之Stencil Testing - 台部落
stencil testing發生在fragment shader之後,depth testing之前,它利用stencil-buffer來捨棄一些片元,餘下的會進入depth testing進...
- 3Stencil Test - OpenGL Wiki
The Stencil Test is a per-sample operation performed after the Fragment Shader. The fragment's st...
- 4走进Stencil Buffer 系列0 : 模板缓冲和模板测试是什么?
模板测试(Stencil Test)是现代渲染流水线的一环,其中涉及到的就是模板缓冲(Stencil Buffer),模板缓冲可以用来制作物体的遮罩、轮廓描边、阴影、 ...
- 5模板测试
当片段着色器处理完片段之后,模板测试(Stencil Test) 就开始执行了,和深度测试 ... 模板测试基于另一个缓冲,这个缓冲叫做模板缓冲(Stencil Buffer),我们被允许在 ...