Testing Vue Apps with Cypress.io (STLJS Meetup April 2018)
Presented at the STLJS Meetup (St Louis, MO)
We dive into a Vue application used in semiconductor labs for transistor measurements. We discuss how get started with E2E testing with Cypress.io. And give a crash course into Vue applications.
Cypress spawns & drives the browser manually exactly like you do in development. Cypress is most often compared with Selenium & Webdriver, but it is not built on either one. What is Cypress? Cypress Best Practices - Brian Mann AssertJS 2018 https://www.youtube.com/watch?v=5XQOK0v_YRE Slides: https://speakerdeck.com/brianmann/cypress-best-practices Brian Mann Founder Cypress.io AssertJS 2018
a way that hasn't been possible before. Cypress provides you a visual interface to indicate which tests and commands are running. What is Cypress? Cypress Best Practices - Brian Mann AssertJS 2018 https://www.youtube.com/watch?v=5XQOK0v_YRE Slides: https://speakerdeck.com/brianmann/cypress-best-practices Brian Mann Founder Cypress.io AssertJS 2018
the interface your component has. The details a user would need to know in order to use your component in an application. Treat the component as a block box. [Where] you’re free to refactor implementation details without rewriting tests.
Props User Action Rendered Output Vue Events Function Calls Props User Action Store Rendered Output Vue Events Function Calls Store Dispatch Outbound Network Request User Action Mocked API
Nano-probing Application on Characterization of 6T-SRAM Single Bit Failures with Different Gox Breakdown Defect Cheng-Piao Lin, et al TSMC Taiwan ISTFA 2014, Utilizing Nanoprobing and Circuit Diagnostics to Identify Key Failure Mechanism of Otherwise Non-Visible Defects in 20nm M. K. Dawood, et al, GLOBALFOUNDRIES Singapore Pte. Ltd. Singapore Native Charts Default Excel Manual Excel ISTFA 2013, SEM-based nanoprobing on 40, 32 and 28nm CMOS devices Challenges for Semiconductor Failure Analysis Erik Paul, et al, GLOBALFOUNDRIES Dresden, Germany Nanoprobing Charts
test your Vue components • Runs the component in the real browser with full power of Cypress • Great talk about this from Gleb Bahmutov @ AssertJS 2018 ◦ https://www.youtube.com/watch?v=5FnalKRjpZk • https://github.com/bahmutov/cypress-vue-unit-test • Promising, interesting to see this steadily improve Cypress - cypress-vue-unit-test
can be slow • Cypress API that look like Promise interface are not 100% Promises ◦ No async/await ◦ Cypress promise automatically gets awaited IF RETURNED. • cy.click({ force: true }) -- hidden elements • Stubbing hot updates from dev server • “Contains” is not an exactly assertion, but it does retry until finds element Cypress - Gotchas
higher level components • Ideal for developers ◦ Iterative feedback ◦ Live debuggability with DOM snapshots • Can be used for full E2E, or for simply more integration-type tests • Leverage all types test varietals • Analyze testing boundaries to guide decision on test varietal Cypress - Closing Thoughts
designed from the ground up to be incrementally adoptable. The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects.”
for each component in the tree. Each component manages its own virtual DOM tree. When you render the tree, we collect dependencies. And when the dependency changes, we re-render that component, and that component only. [We are able] to determine the exact number of components to re-render when something changes.
properties and convert them to getter/setters using Object.defineProperty. (ES5-only feature) The getter/setters are invisible to the user, but under the hood they enable Vue to perform dependency-tracking and change-notification when properties are accessed or modified.”
grants us some deeper access to into the reactivity system, which we can leverage as hooks to observe anything that’s changing. This can be incredibly useful because, as application developers, most of what we’re responsible for are things that change.”
content. • Allows to focus on composition • Scoped Slots → Render props/children • Michael Jackson - Never Write Another HoC - React Phoenix 2017 ◦ https://www.youtube.com/watch?v=BcVAq3YFiuc Vue Slots - Composition
to a team • Makes just enough decisions/conventions for you • Community + Tooling • Progressive • Declarative, Reactive • Composition Vue - Closing Thoughts